akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		
		while(true){
			var s = Console.ReadLine();
			if(s==null)break;
			Sol mySol=new Sol(s);
			Console.WriteLine(mySol.Ans);
		}
	}
}

class Sol{
	String ans;
	public String Ans{
		get{return ans;}
		set{this.ans=value;}
	}
	
	char[][] code;
	void setCode(){
		code=new char[10][];
		String tmp="',.!?";
		code[1]=tmp.ToCharArray();
		tmp="abcABC";
		code[2]=tmp.ToCharArray();
		tmp="defDEF";
		code[3]=tmp.ToCharArray();
		tmp="ghiGHI";
		code[4]=tmp.ToCharArray();
		tmp="jklJKL";
		code[5]=tmp.ToCharArray();
		tmp="mnoMNO";
		code[6]=tmp.ToCharArray();
		tmp="pqrsPQRS";
		code[7]=tmp.ToCharArray();
		tmp="tuvTUV";
		code[8]=tmp.ToCharArray();
		tmp="wxyzWXYZ";
		code[9]=tmp.ToCharArray();
		tmp=" ";
		code[0]=tmp.ToCharArray();
	}
	
	public Sol(String s_in){
		setCode();
		int bufkey=-1;
		int cnt=0;
		String buf="";
		char bufc='\0';
	
		for(int i=0;i<s_in.Length;i++){
			if(bufkey!=s_in[i]-'0'){
				cnt=0;
				if(bufc!='\0'&& bufc!=' ')buf+=bufc.ToString();
				bufkey=s_in[i]-'0';
				bufc=code[bufkey][cnt%(code[bufkey].Length)];
				continue;
			}
			if(bufkey==s_in[i]-'0'){
				cnt++;
				bufc=code[bufkey][cnt%(code[bufkey].Length)];
				if(cnt>0 && bufkey==0)buf+=bufc.ToString();
			}
		}
		if(bufc!=' ')buf+=bufc.ToString();

		ans=buf;
	}
} 

Measured memory_bytes: 5356
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a == c&&b==c) cout << "No";
	else if(a!=b&&a!=c&&b!=c)cout << "No";
	else cout << "Yes";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define data_type long long
#define endl "\n"


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    cin>>str;
    data_type ans=0;
    for(int i=0; i<(1<<(str.size()-1)); i++)
        {
            int pre=0;
            string s;
            for(data_type j=0; j<str.size(); j++)
                {
                    if((1<<j)&i)
                        {
                            s=str.substr(pre,j+1-pre);
                            ans+=stoll(s);
                            pre=j+1;
                            s.clear();
                        }
                }
            if(pre!=str.size())
                {
                    s=str.substr(pre,str.size()+1-pre);
                    ans+=stoll(s);
                }

        }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = "";
		if (a < 0 && b < 0) {
			if ((b - a + 1) % 2 == 0) {
				s = "Positive";
			} else {
				s = "Negative";
			}
		} else if (a <= 0 && b >= 0) {
			s = "Zero";
		} else if (a > 0 && b > 0) {
			s = "Positive";
		}
		System.out.println(s);
	}
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int N;
ll A[200005];
ll B[200005];
ll C[200005];
ll D[35];

//! under以上になる最小のindex
inline int getUnder(ll under)
{
    if (under <= 0)
        return 0;
    int ok = N, ng = -1;
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        if (C[mid] >= under)
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    return ok;
}
//! top未満になる最大のindex
inline int getTop(ll top)
{
    int ok = -1, ng = N;
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        if (C[mid] < top)
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    return ok;
}

int main()
{
    cin >> N;
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, N)
    {
        cin >> B[i];
    }
    REP(i, 30)
    {
        ll m = 0;
        D[i] = 0;
        REP(j, i + 1)
        {
            m |= (1 << j);
        }
        REP(j, N)
        {
            C[j] = (B[j] & m);
        }
        sort(C, C + N);

        ll u = pow((ll)2, i);
        ll t = pow((ll)2, (i + 1));
        REP(j, N)
        {
            ll a = A[j] & m;
            {
                int ui = getUnder(u - a);
                int ti = getTop(t - a);
                if (ui <= ti)
                {
                    D[i] += (ti - ui + 1);
                }
            }
            {
                int ui = getUnder(u + t - a);
                int ti = getTop(2 * t - a);
                if (ui <= ti)
                {
                    D[i] += (ti - ui + 1);
                }
            }
        }
    }

    ll ans = 0;
    REP(i, 30)
    {
        ans |= ((D[i] % 2) << i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<double, pair<int, int> >  edge;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

llint N;
double x[15], y[15];
llint a[15];
double G[15][15];
vector<edge> E;
UnionFind uf(16);

double mst[1<<15];
double sum[1<<15];
double dp[1<<15];

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> x[i] >> y[i] >> a[i];
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(i == j) G[i][j] = 0.0;
			else{
				G[i][j] = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
			}
		}
	}
	
	int S = 1 << N;
	for(int s = 0; s < S; s++){
		E.clear();
		for(int i = 0; i < N; i++){
			if((s & (1<<i)) == 0) continue; 
			for(int j = 0; j < N; j++){
				if(i >= j) continue;
				if((s & (1<<j)) == 0) continue; 
				E.push_back(make_pair(G[i][j], make_pair(i, j)));
			}
		}
		sort(E.begin(), E.end());
		uf.init();
		double sum = 0;
		for(int i = 0; i < E.size(); i++){
			edge e = E[i];
			if(uf.same(e.second.first, e.second.second)) continue;
			uf.unite(e.second.first, e.second.second);
			sum += e.first;
		}
		mst[s] = sum;
	}
	for(int s = 0; s < S; s++){
		for(int i = 0; i < N; i++){
			if(s & (1<<i)) sum[s] += a[i];
		}
	}
	
	vector<int> vec;
	dp[0] = -inf;
	for(int s = 1; s < S; s++){
		vec.clear();
		for(int i = 0; i < N; i++) if(s & (1<<i)) vec.push_back(i);
		int n = vec.size();
		dp[s] = (sum[s] - mst[s]) / n;
		for(int i = 0; i < (1<<n); i++){
			int bit = 0, cbit = 0;
			for(int j = 0; j < n; j++){
				if(i & (1<<j)) bit |= (1<<vec[j]);
				else cbit |= (1<<vec[j]);
			}
			dp[s] = max(dp[s], min(dp[bit], dp[cbit]));
		}
	}
	
	//for(int i = 1; i < S; i++) cout << dp[i] << " ";  cout << endl;
	
	printf("%.11f\n", dp[S-1]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX_N = 1e4+5;
const LL MOD = 1e9+7;

int N, a[MAX_N];
unordered_map<int, int> m;

int quickpow(int a, int x, int mod)
{
    if (x == 0) return 1;
    LL ans = quickpow(a, x/2, mod);
    ans = (ans*ans)%mod;
    if (x%2 == 1) ans = (ans*a)%mod;
    return ans;
}

int rev(int a, int mod)
{
    return quickpow(a, mod-2, mod);
}

int main()
{
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &a[i]);
        int e = a[i];
        for (int j = 2; j*j <= a[i]; j++)
        {
            int cnt = 0;
            while (e%j == 0)
            {
                cnt++;
                e /= j;
            }
            if (cnt) m[j] = (m.count(j) ? max(m[j], cnt) : cnt);
        }
        if (e > 1) m[e] = (m.count(e) ? max(m[e], 1) : 1);
    }
    LL lcm = 1;
    for (auto it:m)
    {
        lcm = (lcm*quickpow(it.first, it.second, MOD)) % MOD;
    }

    LL ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += (lcm*rev(a[i], MOD)) % MOD;
        ans %= MOD;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
using namespace std;
vector<int> v;
const long long MAX = 1e15;
vector<vector<long long>> dp;
signed main(){
    int n, k;
    cin >> n >> k;
    v.resize(n+1);
    dp.resize(n+1);
    for(int i = 0; i <= n; i++){
        dp[i].resize(k+1,MAX);
        if(i)cin >> v[i];
    }
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int e = 0; e <= i; e++){
            for(int j = k; j >= 0; j--){
                dp[i+1][j] = min(dp[i+1][j], dp[e][j] + max(0, v[i+1]-v[e]));
                dp[e][j] = j?dp[e][j-1]:MAX;
            }
        }
    }
    long long ans = MAX;
    for(int i = 0; i <= n; i++)for(int j = 0; j <= k; j++)ans = min(ans, dp[i][j]);
    cout << ans << endl;
}


Measured memory_bytes: 1024
using Yorukatsu035.Questions;
using Yorukatsu035.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu035.Questions
{
    /// <summary>
    /// ABC122 A
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var b = inputStream.ReadLine()[0];

            switch (b)
            {
                case 'A':
                    yield return 'T';
                    yield break;
                case 'T':
                    yield return 'A';
                    yield break;
                case 'C':
                    yield return 'G';
                    yield break;
                case 'G':
                    yield return 'C';
                    yield break;
                default:
                    break;
            }
        }
    }
}


namespace Yorukatsu035
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu035.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu035.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11092
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()

def train(X, Y, T):  # O(N)    ans: 回数
    ans = 0
    for i in range(len(X)):
        ans += max(0, X[i] - T // Y[i])
    return ans


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))
    A.sort(reverse=True)  # 0(NlogN)
    F.sort()  # O(NlogN)

    t =A[0]*(10**6)

    if K>=t:
        print(0)
        exit()

    ok = t+1 #時間
    ng = -1

    # O(Nlog(maxK)?)
    while ok - ng > 1:
        mid = (ok + ng) // 2 #時間
        ans = train(A,F,mid)  #kaisuu
        if ans >K:
            ng =mid
        else:
            ok =mid

    print(ok)


if __name__ == "__main__":
    main()


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

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

    int count = 0;
    for(int i = 1; i < s.size()+1; i++){
        if(s[i-1] == s[i]){
            count++;
            if(s[i-1] == '0'){
                s[i] = '1';
            }else{
                s[i] = '0';
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 512
N = int(input())
A = [int(input()) for _ in range(N)]

cnt = 0
remain = 0
for n in range(N):
    if A[n] == 0:
        remain = 0
        continue
    cnt += (A[n]+remain)//2 
    remain = (A[n]+remain)%2
print(cnt)

Measured memory_bytes: 7072
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		Scanner sc =new Scanner(System.in);
		while(sc.hasNext()) {
		double v = sc.nextDouble();
		double y= 4.9*(v/9.8)*(v/9.8);
		double ans=(y+5.0)/5.0;
		System.out.println((int)Math.ceil(ans));
		}
	}

}


Measured memory_bytes: 27784
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, s, e) for(int i = s; i < (e); i++)
#define All(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const LL INF = 1010101010101010;

struct edge {
    int src, to;
    LL cost;
    edge(int to, LL cost) :
        src(-1), to(to), cost(cost) {}
    edge(int src, int to, LL cost) :
        src(src), to(to), cost(cost) {}
};
using Graph = vector<vector<edge> >;
using UWGraph = vector<vector<int> >;

vector<LL> BellmanFord(vector<edge> &edges, int V, int st, int gl) {
    vector<LL> dist(V, INF);
    dist[st] = 0;
    REP(i, V - 1) {
        for(auto &e : edges) {
            if(dist[e.src] == INF) continue;
            dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
        }
    }
    vector<bool> negative(V, false);
    for(auto &e : edges) {
        if(dist[e.src] == INF) continue;
        if(dist[e.src] + e.cost < dist[e.to]) negative[e.to] = true;
        if(negative[e.src]) negative[e.to] = true;
    }
    if(negative[gl]) return vector<LL>();
    return dist;
}

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

    int N, M;
    cin >> N >> M;
    vector<edge> edges;
    REP(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edges.pb(edge(a, b, -c));
    }

    vector<LL> dist = BellmanFord(edges, N, 0, N - 1);
    // REP(i, M) cout << edges[i].src << " " << edges[i].to << " " << edges[i].cost << endl;
    // REP(i, N) cout << dist[i] << endl;
    if(dist == vector<LL>())
        cout << "inf" << endl;
    else {
        cout << -dist[N - 1] << endl;
    }

    return 0;
}

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

int dfs(int v, int N, vector<vector<int>> graph, vector<bool> visited) {
  bool all_visited = true;
  for (int i=0; i<N; i++)
    if (!visited.at(i)) all_visited = false;
  
  if (all_visited) return 1;
  
  int pathc = 0;
  for (int i=0; i<N; i++) {
    if (!graph.at(v).at(i)) continue;
    else if (visited.at(i)) continue;
    else {
      visited.at(i) = true;
      pathc += dfs(i, N, graph, visited);
      visited.at(i) = false;
    }
  }
  return pathc;
} 

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  for (int i=0; i<M; i++) cin >> a.at(i) >> b.at(i);
  vector<vector<int>> graph(N, vector<int>(N));
  for (int i=0; i<M; i++) {
    graph.at(a.at(i)-1).at(b.at(i)-1) = 1;
    graph.at(b.at(i)-1).at(a.at(i)-1) = 1;
  }
  
  vector<bool> visited(N, false);
  visited.at(0) = true;
  int all_path = dfs(0, N, graph, visited);
  cout << all_path << endl;
}

Measured memory_bytes: 256
n=int(input())
S=[]
for i in range(n):
    S.append(input())

from collections import defaultdict
d = defaultdict(lambda:0)

for k in S:
    d[str(k)]+=1

ansn=0
ans=[]
for i in set(S):
    if d[i]>ansn:
        ansn=d[i]
        ans=[]
    if d[i]==ansn:
        ans.append(i)

ans=sorted(ans)
for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 44292
#include <stdio.h>

#include <iostream>

using namespace std;
int main() {
    long long int N, Y;
    cin >> N >> Y;
    for (int j = 0; j <= N; j++) {
        for (int i = 0; i <= N - j; i++) {
            if ((N - i - j) * 1000 + i * 5000 + j * 10000 == Y) {
                cout << j << " " << i << " "
                     << " " << (N - j - i) << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        struct Point
        {
            public double x { get; set; }
            public double y { get; set; }

            public static double distance(Point lhs, Point rhs)
            {
                double x = lhs.x - rhs.x;
                double y = lhs.y - rhs.y;
                return Math.Sqrt(x * x + y * y);
            }
        }

        static void Main(string[] args)
        {
            var input = Console.In.ReadLine();
            var strings = input.Split(' ');

            if (strings.Length != 4)
            {
                return;
            }

            Point p1 = new Point { x = double.Parse(strings[0]), y = double.Parse(strings[1]) };
            Point p2 = new Point { x = double.Parse(strings[2]), y = double.Parse(strings[3]) };

            Console.Out.WriteLine("{0:0.########}", Point.distance(p1, p2));
        }
    }
}



Measured memory_bytes: 18024
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }

int main(){
	FASTIO;
	ll n, r; cin >> n >> r;
	if (n >= 10)
		cout << r << endl;
	else
		cout << r + 100 * (10 - n) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

struct edge {
	vi to;
};

int ans = 0,n;
vector<edge> g;
vector<bool> b;

void dfs(int node, int num) {
	if (num==n) {
		ans++;
		return;
	}
	b[node] = true;
	rep(i, g[node].to.size()) {
		if (!b[g[node].to[i]]) {
			dfs(g[node].to[i], num + 1);
		}
	}
	b[node] = false;
}

int main() {
	int m,in,inn;
	cin >> n >> m;
	g.resize(n);
	b.resize(n);
	rep(i, n) {
		b[i] = false;
	}
	rep(i, m) {
		cin >> in >> inn;
		g[in - 1].to.push_back(inn - 1);
		g[inn - 1].to.push_back(in - 1);
	}
	dfs(0, 1);
	cout << ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b;
   cin >> a >> b;
   cout << max({a+b,a-b,a*b}) << '\n';
   return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
	int a,b;
    cin >> a >> b;
    a *= b;
    if(a%2==0){
      cout << "Even" << endl;
    }else{
      cout << "Odd" << endl;
    }
    return 0;
  } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // string s;
    // cin>>s;
   	// int flag=1;
    // for(int i=0;i<s.size();++i){
    // 	for(int j=i+1;j<s.size();++j){
    // 		if(s[i]==s[j]){
    // 			flag=0;
    // 			break;
    // 		}
    // 	}
    // }
    // cout<<((flag)?"yes":"no");



    // string s;
    // cin>>s;
    // set<char>c;
    // for(char k:s) c.insert(k);
    // cout<<((s.size()==c.size())?"yes":"no");
    


    // string s;
    // cin>>s;
    // map<char,int>m;
    // for(int i=0;i<s.size();++i){
    // 	if(m[s[i]]>0){
    // 		cout<<"no";
    // 		return 0;
    // 	}
    // 	++m[s[i]];
    // }
    // cout<<"yes";

    // int a,b;
    // cin>>a>>b;
    // int ans=a+b;
    // (ans>=10)?cout<<"error":cout<<ans;
    

    // int n;
    // cin>>n;
    // int a,mx=0,mi=1000;
    // for(int i=0;i<n;++i){
    // 	cin>>a;
    // 	if(mx<a) mx=a;
    // 	if(mi>a) mi=a;
    // }


    // int n;
    // cin>>n;
    // int ar[n];
    // for(int i=0;i<n;++i) cin>>ar[i];
   	// cout<<*max_element(ar,ar+n)-*min_element(ar,ar+n);
    

    // int n,m;
    // cin>>n>>m;
    // n+=2;
    // m+=2;
    // for(int i=0;i<n;++i){
    // 	for(int j=0;j<m;++j){
    // 		if(i==0 || i==n-1 || j==0 || j==m-1) cout<<"#";
    // 		else{
    // 			char c;
    // 			cin>>c;
    // 			cout<<c;
    // 		}
    // 	}
    // 	cout<<'\n';
    // }

    // int x,y;
    // cin>>x>>y;
    // int ar[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    // cout<<((ar[x]==ar[y])?"Yes":"No");
    

    // string a,b,c;
    // cin>>a>>b>>c;
    // cout<<(((a.back()==b.front()) && (b.back()==c.front()))?"YES":"NO");
    
    // int a,b,c;
    // cin>>a>>b>>c;
    // cout<<((a<=c && c<=b)?"Yes":"No");
   
	// string s(3,'0');
	// for(int i=0;i<3;++i) cin>>s.at(i);
	// int x=stoi(s);
	// cout<<((x%4==0)?"YES":"NO");       

    // int a,b,c;
    // cin>>a>>b>>c;
    // cout<<(((b*10+c)%4==0)?"YES":"NO");

    // int n,m;
    // cin>>n>>m;
    // m*=2;
    // int ar[m];
    // for(int i=0;i<m;++i) cin>>ar[i];
    // for(int i=1;i<=n;++i) cout<<count(ar,ar+m,i)<<'\n'; 
   
    // int n,m;
    // cin>>n>>m;
    // vector<int>num(n,0);
    // for(int i=0;i<m;++i){
    // 	int a,b;
    // 	cin>>a>>b;
    // 	++num.at(a-1);
    // 	++num.at(b-1);
    // }
    // for(int i=0;i<n;++i) cout<<num[i]<<'\n';
   
    int a,b,c;
    cin>>a>>b>>c;
    int flag=0;
    for(int i=1;i<=b;++i){
    	if(a*i%b==c){
    		flag=1;
    		break;    
    	}
    }
    cout<<((flag)?"YES":"NO");
   return 0;
}

Measured memory_bytes: 3520
package main

import (
	"fmt"
)

func main() {
	var (
		a, b, c, x int
		counter    = 0
		total int
	)

	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&x)

	for i := 0; i <= a; i++ {
		if i * 500 > x {
			break
		}
		for j := 0; j <= b; j++ {
			if i * 500 + j * 100 > x {
				break
			}
			for k := 0; k <= c; k++ {
				total = i * 500 + j * 100 + k * 50
				if i * 500 + j * 100 + k * 50 > x {
					break
				}
				if total == x {
					counter++
				}
			}
		}
	}
	fmt.Println(counter)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define INF 1<<30
#define MAX 100005
#define ll long long
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
ll dp[100005][2];
ll solve(ll stones,ll player,vector<ll>A){
    if(stones<=0)
        return player^1;
    if(dp[stones][player]!=-1)
        return dp[stones][player];
    ll ans;
    if(!player){
        ans=10;
        for(auto a:A){
            if(stones-a>=0)
                ans=min(ans,solve(stones-a,1,A));
            else
                ans=min(ans,1LL);
        }
    }
    else{
        ans=0;
        for(auto a:A){
            if(stones-a>=0)
                ans=max(ans,solve(stones-a,0,A));
            else
                ans=max(ans,0LL);
        }
    }
    return dp[stones][player]=ans;
}
int main()
{
    speed;
    ll N,K;
    cin>>N>>K;
    vector<ll>A(N);
    for(ll i=0;i<N;i++) cin>>A[i];
    memset(dp,-1,sizeof(dp));
    if(N==1){
        if((K/A[0])%2) cout<<"First";
        else cout<<"Second";
        return 0;
    }
    ll x=solve(K,0,A);
    if(!x) cout<<"First";
    else cout<<"Second";
}


Measured memory_bytes: 97152
import java.util.Scanner;

public class Main {

	static class Node<E> {
		public E value;
		public Node<E> next;		
		public Node(E value) {
			this.value = value;
			this.next = null;
		}
	}

	static class SimpleQueue<E> {
		
		private Node<E> head;
		private Node<E> tail;
		private int size;
		
		public SimpleQueue() {
			size = 0;
			head = null;
			tail = null;
		}
		
		public int getSize() {
			return size;
		}
		
		public boolean isEmpty() {
			return size == 0;
		}
		
		public void enqueue(E element) {
			Node<E> node = new Node<E>(element);
			if (head == null && tail == null) {
				head = tail = node;
			} else {
				tail.next = node;
				tail = node;
			}
			size++;
		}
		
		public E dequeue() {			
			if (isEmpty()) {
				return null;
			}
			E element = head.value;
			head = head.next;
			if (head == null) {
				tail = null;
			}
			size--;
			return element;			
		}
		
		public String toString() {
			StringBuilder sb = new StringBuilder();
			sb.append("[");
			Node<E> current = head;
			while (current != null) {
				sb.append(current.value);
				current = current.next;
				if (current != null) {
					sb.append(", ");
				}
			}			
			sb.append("](");
			if (tail != null) {
				sb.append(tail.value);
			}
			sb.append(")");
			return sb.toString();
		}		
	}
	
	static class Process {		
		public String name;
		public int time;		
		public Process(String name, int time) {
			this.name = name;
			this.time = time;
		}
	}
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int q = sc.nextInt();
		
		SimpleQueue<Process> queue = new SimpleQueue<Process>();
		for (int i = 0; i < n; i++) {
			String name = sc.next();
			int time = sc.nextInt();
			queue.enqueue(new Process(name, time));
		}
		sc.close();

		int total = 0;
		while (!queue.isEmpty()) {
			
			Process process = queue.dequeue();
			int time = process.time;
			total += Math.min(time, q);
			if (time > q) {
				process.time = time - q;
				queue.enqueue(process);
			} else {
				System.out.println(process.name + " " + total);
			}
		}
	}
}



Measured memory_bytes: 78768
#include<bits/stdc++.h>
using namespace std;
int main() {
  vector<int> cnt[256];
  vector<char> alp(26);
  iota(alp.begin(), alp.end(), 'a');
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    for (char c : alp) {
      cnt[c].push_back(count(s.begin(), s.end(), c));
    }
  }
  for (char c : alp) {
    cout << string(*min_element(cnt[c].begin(), cnt[c].end()), c);
  }
  cout << endl;
}

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

int main(){
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    long long ans = 0;
    for (int i = 0; i <= 3000; i++){
        for (int j = 0; j <= 3000; j++){
            if (0 <= n - r*i - g*j && (n - r*i - g*j) % b == 0) ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;
int A,B,C,D,E,F;
int water[3005],sugar[3005];
int main(){
	cin>>A>>B>>C>>D>>E>>F;
	water[0]=sugar[0]=1;
	for(int i=1;i<=F;i++){
		if(i>=100*A)water[i]=water[i-100*A];
		if(i>=100*B) water[i]=(water[i]|water[i-100*B]);
		if(i>=C) sugar[i]=sugar[i-C];
		if(i>=D) sugar[i]=(sugar[i]|sugar[i-D]);
	}
	int ansx=100*A;
	int ansy=0;
	for(int x=1;x<=F;x++){
		if(water[x]==1){
			for(int y=0;y<=F-x;y++) if(sugar[y]==1){
			double s=y*1.0/x;
			double t=E*1.0/100;
			double u=ansy*1.0/ansx;
			
			if(s<=t&&s>u){
				ansx=x;
				ansy=y;
			}
		}
		}
	}
	cout<<ansx+ansy<<" "<<ansy<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int A, B;
	cin >> A;
	cin >> B;
	if ((A+B)%2==0)
	{
		cout << (A + B) / 2 << endl;
	}
	else
	{
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

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

int main() {
	string S;
	cin >> S;
	int N = S.size();
	long long counter = 0;
	int black = N - 1;;
	for (int i = N - 1; i >= 0; i--) {
		if (S[i] == 'B') {
			counter += black - i;
			black--;
		}
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

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

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int i;
  ll n, k; cin >> n >> k;
  ll sum[n+1]; sum[0] = 0;
  repd(i,1,n+1){sum[i] = sum[i-1] + i;}
  ll ans = 0;

  FOR(i,k,n+1){ans += sum[n] - sum[n-i] - sum[i-1] + 1; ans %= MOD;}
  ans++; ans %= MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5132
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000007

int main() {
	long long int x, y;
	cin >> x >> y;
	int i=0;
	while (x <= y) {
		i++;
		x *= 2;
	}
	cout << i;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	   cin>>arr[i];
	if(n<3)
	{
		cout<<"0\n";
		return 0;
	}
	int count=0;
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				int a=arr[i];
				int b=arr[j];
				int c=arr[k];
				if(a==b || a==c || b==c)
				   continue;
				if(a<(b+c) && b<(a+c) && c<(a+b))
				     count++;
			}
		}
	}
	cout<<count<<"\n";
}


Measured memory_bytes: 3628
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

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

    }
    for( int i = 0; i < n; ++i ) {
        if( cnt + 1 == v[i] ) ++cnt;

    }
    if( cnt == 0 ) cout << -1 << endl;
    else cout << n - cnt << endl;
    return 0;
}



Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val m = scanner.nextInt()
    val height = IntArray(n)
    val path = Array(m, {Pair<Int, Int>(0,0)})
    for(i in 0..n-1){
        height[i] = scanner.nextInt()
    }
    for(i in 0..m-1){
        var pair = Pair(scanner.nextInt(), scanner.nextInt())
        path[i] = pair
    }
    val good = Array(n, {1})
    for(i in 0..m-1){
        if(height[path[i].first-1] > height[path[i].second-1]){
            good[path[i].second-1]--
        }
        else if(height[path[i].first-1] < height[path[i].second-1]){
            good[path[i].first-1]--
        }
        else{
            good[path[i].first-1]--
            good[path[i].second-1]--
        }
    }
    var count = 0
    for(i in 0..n-1){
        if(good[i] > 0) count++
    }
    println(count)
}

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

int main(){
  long long N,K,i,k,n,c,cp;
  cin >> N >> K;
  vector<int> A(N);
  vector<int> r;
  vector<int> odr(N+1,-1);
  for(auto &x:A)
    cin >> x;
  n = 1;
  while(odr[n] == -1){
    odr[n] = r.size();
    r.push_back(n);
    n = A[n-1];
  }
  cp = odr[n];
  c = r.size()-cp;
  if (K>=cp){
    K -= cp;
    k = (K % c) + cp;
  }
  else
    k = K;
  cout << r[k] << endl;
  
  return 0;
}

Measured memory_bytes: 5828
#include<bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
signed main(){

#ifndef ONLINE_JUDGE
  //  freopen("input.txt","r", stdin);
#endif

    fastIO

    int n,k;
    cin >> n >> k;
    int arr[n],dp[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
        dp[i] = 0;
    }
    dp[1] = abs(arr[0] - arr[1]);
    for(int i=2;i<n;i++){
        for(int j=1;j<=min(i,k);j++){
            if(j == 1){
                dp[i] = dp[i-1] + abs(arr[i-1] - arr[i]);
            }else{
                dp[i] = min(dp[i], dp[i-j] + abs(arr[i-j] - arr[i]));
            }
        }
    }
    cout << dp[n-1];

    return 0;
}


Measured memory_bytes: 1792
<>;
map{push@$_,$_[--$|]for@_=glob}<>;
$==1e9+7;
sub f{my($x,$b,$w)=($_,1,1);$_-"@_"and($c,$d)=f($x),$b=$b*$c%$=,$w=$w*$d%$=for@$x;$w,$b+$w}
print+(f++$_)[1]%$=

Measured memory_bytes: 188032
import java.util.Scanner;
public class Main{
	public static  void main(String[] args){

	Scanner sc = new Scanner(System.in);
	while(true){
		int H = sc.nextInt();
		int W = sc.nextInt();
		if(H==0 && W==0){
			break;
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
			int sum=i+j;
			if(sum%2==0){
				System.out.printf("#");
			
			}else{
				System.out.printf(".");
			}
			}
			System.out.printf("\n");
		}
			System.out.printf("\n");
	}
	}

}

Measured memory_bytes: 63900
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
As = list(mapint())
mod = 10**9+7
As.sort()

pos = {}
neg = {}
pos[0] = 1
neg[0] = 1
for i in range(1, 10**5+3):
    pos[i] = (pos[i-1]*i)%mod
    neg[i] = pow(pos[i], mod-2, mod)

mini = 0
maxi = 0
for i, a in enumerate(As):
    if i<=N-K:
        mini += a*pos[(N-i-1)]*neg[K-1]*neg[N-i-K]
        mini %= mod
    if i>=K-1:
        maxi += a*pos[i]*neg[K-1]*neg[i-K+1]
        maxi %= mod
print((maxi-mini)%mod)

Measured memory_bytes: 113292
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    char op;
    while(true){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '?') break;
        switch(op){
        case '+':
            printf("%d\n",a+b);
            break;
        case '-':
            printf("%d\n",a-b);
            break;
        case '/':
            printf("%d\n",a/b);
            break;
        case '*':
            printf("%d\n",a*b);
            break;
        }
    }
}



Measured memory_bytes: 2728
import numpy as np
L, R = [int(x) for x in input().split(" ")]
N = 2019

minimum_mod = N
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if (i * j) % N == 0:
            print(0)
            exit(0)
        elif (i * j) % N < minimum_mod:
            minimum_mod = (i * j) % N

print(minimum_mod)

Measured memory_bytes: 12424
#include <stdio.h>

int main()
{
	int i, N, M, a[51], b[51];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) scanf("%d %d", &(a[i]), &(b[i]));
	
	int deg[51] = {};
	for (i = 1; i <= M; i++) {
		deg[a[i]]++;
		deg[b[i]]++;
	}
	
	for (i = 1; i <= N; i++) printf("%d\n", deg[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#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 X;
    cin >> X;

    if (400 <= X && X <= 599) {
        cout << 8 << endl;
    } else if (600 <= X && X <= 799) {
        cout << 7 << endl;
    } else if (800 <= X && X <= 999) {
        cout << 6 << endl;
    } else if (1000 <= X && X <= 1199) {
        cout << 5 << endl;
    } else if (1200 <= X && X <= 1399) {
        cout << 4 << endl;
    } else if (1400 <= X && X <= 1599) {
        cout << 3 << endl;
    } else if (1600 <= X && X <= 1799) {
        cout << 2 << endl;
    } else if (1800 <= X && X <= 1999) {
        cout << 1 << endl;
    }

    return 0;
}

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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

const int MAX = 30;
int xl[MAX], xr[MAX], h[MAX];
int maxHeight[MAX * 2 + 10];

bool solve() {
  int r, n;
  scanf("%d%d", &r, &n);
  if (r == n && r == 0) {
    return false;
  }
  memset(maxHeight, 0, sizeof(maxHeight));
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", xl + i, xr + i, h + i);
    for (int j = xl[i] + MAX; j < xr[i] + MAX; j++) {
      maxHeight[j] = max(maxHeight[j], h[i]);
    }
  }
  double high = MAX, low = 0;
  for (int cnt = 0; cnt < 100; cnt++) {
    const double mid = (high + low) / 2;
    bool out = false;
    
    for (int i = MAX - r + 1; i < MAX + r; i++) {
      double nowHeight = 1. * mid + sqrt(r * r - (i - MAX) * (i - MAX)) - r;
      if (maxHeight[i - 1] < nowHeight || maxHeight[i] < nowHeight) {
        out = true;
        break;
      }
    }
    
    if (out) {
      high = mid;
    } else {
      low = mid;
    }
  }
  printf("%.10lf\n", low);
  return true;
}

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

Measured memory_bytes: 3192
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    const int N = 50;
    vector<vector<long>> com;
    vector<long> comtemp;
    comtemp.push_back(1);
    com.push_back(comtemp);

    for(int i=1; i<=N; i++){
        vector<long> v;
        com.push_back(v);

        for(int j=0; j<=i; j++){
            if(j == 0 || j == i){
                com[i].push_back(1);
            }
            else{
                com[i].push_back(com[i-1][j-1] + com[i-1][j]);
            }
        }
    }


    int n, p; cin >> n >> p;

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

    int cnteven = 0;
    int cntodd = 0;
    for(int i=0; i<n; i++){
        if(a[i] % 2 == 0){
            cnteven++;
        }
        else{
            cntodd++;
        }
    }

    long long ans = 0;
    if(p == 0){
        for(int i=0; i<=cntodd; i+=2){
            ans += com[cntodd][i];
        }
        ans *= (long long)pow(2.0, cnteven);
    }
    else{
        for(int i=1; i<=cntodd; i+=2){
            ans += com[cntodd][i];
        }
        ans *= (long long)pow(2.0, cnteven);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
while n = STDIN.gets.chomp.to_i
  if n == 0 then break end
  a=[]
  n.times do
    a.push(STDIN.gets.chomp.to_i)
  end
  max_sum=-1000000000
  (-1...a.length).each do |i|
    sum=0
    (i+1...a.length).each do |j| 
      sum += a[j]
      if max_sum < sum then max_sum = sum end
    end
  end 
  puts max_sum
end

Measured memory_bytes: 8784
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;

public class Main {

    static final int modnum = 1000000007;

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

        Arrays.sort(a);

        // HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
        ArrayList<SimpleEntry<Integer,Integer>> list = new ArrayList<SimpleEntry<Integer,Integer>>();

        for(int i=0;i<M;i++){
            int b = sc.nextInt();
            int c = sc.nextInt();
            // if(map.containsKey(c))
            //     map.put(c,map.get(c)+b);
            // else
            //     map.put(c,b);
            list.add(new SimpleEntry<Integer,Integer>(c,b));
        }

        Collections.sort(list,Comparator.comparing(SimpleEntry<Integer,Integer>::getKey).reversed());

        int j = 0;
        for(int i=0;i<list.size();i++){
            SimpleEntry<Integer,Integer> pair = list.get(i);
            // System.out.println(pair.toString());
            for(int k=0;k<pair.getValue();k++){
                if(j < N && a[j]<pair.getKey())
                    a[j++]=pair.getKey();
                else
                    break;
            }
        }

        long ans = 0;
        for(int i=0;i<N;i++){
            ans+=a[i];
        }

        // System.out.println(Arrays.toString(a));
        System.out.println(ans);
    }
}

Measured memory_bytes: 95392
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define int long long    // %d=>%lld
#define pb push_back
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;

const int MAX_n = 100000;
int n,h;
int a;
int b;

vector<int> remains;

bool solve(int mid){
    int sum=0;
    for(int x:remains){
        if(x-mid*b>0){
            sum+=(x-mid*b+(a-b-1))/(a-b);
        }
    }
    if(sum<=mid){
        return true;
    }else {
        return false;
    }
}



signed main(){
    scanf("%lld", &n);

    scanf("%lld", &a);
    scanf("%lld", &b);


    for(int i = 0;i < n;i++){
        scanf("%lld", &h);
        remains.pb(h);
    }


    int ok=INF;
    int ng=0;

    while (abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        if(solve(mid)){
            ok=mid;
        }else{
            ng = mid;
        }
    }

    printf("%lld\n", ok);

    return 0;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int main (){
    int n;
    scanf("%d", &n);
    vector<int> data;
    int result = 1;
    int flag = 0;
    int last;
    for (int i = 0; i < n; i++) {
        int temp;
        scanf("%d", &temp);
        if (i == 0) {
            last = temp;
        }
        else {
            if (temp > last) {
                if (flag == 0)
                    flag = 1;
                if (flag == -1) {
                    flag = 0;
                    result++;
                }
            }
            if (temp < last) {
                if (flag == 0)
                    flag = -1;
                if (flag == 1) {
                    result++;
                    flag = 0;
                }
            }
            last = temp;
        }
    }

        printf("%d", result);
    
}


Measured memory_bytes: 128