akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int h = cin.Int();
			int n = cin.Int();
			var ab = new Tuple<int, int>[n];
			for (int i = 0; i < n; i++) {
				int a = cin.Int();
				int b = cin.Int();
				ab[i] = new Tuple<int, int>(a, b);
			}

			var dp = new long[h + 1];
			for (int j = 0; j <= h; j++) {
				dp[j] = long.MaxValue;
			}

			for (int i = 0; i < n; i++) {
				int damage = Math.Min(ab[i].Item1, h);
				dp[damage] = Math.Min(dp[damage], ab[i].Item2);
			}

			for (int i = 0; i < h; i++) {
				if (dp[i] == long.MaxValue) {
					continue;
				}

				for (int j = 0; j < n; j++) {
					int damage = Math.Min(i + ab[j].Item1, h);
					long mp = dp[i] + ab[j].Item2;
					dp[damage] = Math.Min(dp[damage], mp);
				}
			}

			long ans = dp[h];
			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11260
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	string X;
	cin >> X;
	int k=0;

	for(int i=0; i < X.length(); i++){
		char buf = X[i];

		if(X[i] == 'o'){
			k++;
		}
	}


	if((k+15-X.length()) >=8){
		cout << "YES" <<endl;
	}else{
		cout << "NO" <<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
using namespace std;
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s[1001];
	//long long n, A[1000000000];
	long long n, m;
	//string s;
	cin >> n;
	cin >> m;
	cin >> d;
	/*for (a = 1; a <= n; a++)
	{
		for (b = 1; b <= n; b++)
		{
			if (abs(a-b)==d)
			{
				c++;
			}
		}
	}*/
	//c = (n - d) * 2 * (pow(n, m - 1))*(m - 1);
	//cout << c << endl;
	//std::cout << std::fixed;
	//cout << std::setprecision(20) << (double)c*(m - 1) / (pow(n, m)) << endl;


	c = (n - d) * 2 * (m - 1);
	if (d==0)
	{
		c /= 2;
	}
	cout << std::setprecision(30) << (double)c / (n*n) << 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);
		int a=sc.nextInt();
		String op=sc.next();
		int b=sc.nextInt();
		int ans=0;

		if (op.equals("+")) ans=a+b;
		else if(op.equals("-")) ans=a-b;
		
		System.out.println(ans);	
	}
	
} 

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

int main() {
  int A, B;
  cin >> A >> B;
  for (int i = 1; i <= 1010; i++) {
    int a, b;
    a = 0.08 * i;
    b = 0.1 * i;
    if (a == A && b == B) {
      cout << i << endl;
      break;
    }
    if (i == 1010) {
      cout << -1 << endl;
    }
  }
}


Measured memory_bytes: 256
using System;

namespace AtCoder.DP
{
    class EDPC_T
    {
        public const int mod = 1000000007;

        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var dp = new long[n, n];
            var acc = new long[n];
            for (int i = 0; i < n; i++)
                dp[0, i] = 1;


            for (int i = 0; i < s.Length; i++)
            {
                acc[0] = dp[i, 0];
                for (int j = 1; j < n - i; j++)
                    acc[j] = (acc[j - 1] + dp[i, j]) % mod;

                if (s[i] == '<')
                {
                    for (int j = 0; j < n - i - 1; j++)
                        dp[i + 1, j] = acc[j];
                }
                else
                {
                    for (int j = 0; j < n - i - 1; j++)
                        dp[i + 1, j] = (acc[n - i - 1] - acc[j] + mod) % mod;
                }
            }
            Console.WriteLine(dp[n - 1, 0] % mod);
        }
    }
}

Measured memory_bytes: 81240
s=input()
t=input()
x=list(s)
y=list(t)
import sys
if len(set(y)-set(x))!=0:
	print(-1)
	sys.exit()
a=[[] for _ in range(26)]
for i in range(len(s)):
	a[ord(x[i])-97].append(i)
import bisect

repeat=0
last=-1
for i in range(len(t)):
	temp=a[ord(y[i])-97]
	if last>=temp[-1]:
		repeat+=1
		last=temp[0]
	else:
		last=temp[bisect.bisect_right(temp,last)]
	#print(temp,repeat,last)
print(repeat*len(s)+last+1)

Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
string ss;
int ans=0;
int main(){
  cin>>ss;
  int l=ss.size();
  int r=0,s=l-1;
  while(r<s){
    if(ss[r]!=ss[s]) ans++;
    r++;
    s--;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

struct segment {
    int l,r;
    long long mx;
};

segment t[600006];
long long dp[200005];
int h[200005],a[200005];

void build(int l,int r,int idx) {
    t[idx] = {l,r,0};
    if (l == r)
        return;

    int mid;

    mid = (l + r) >> 1;

    build(l,mid,(idx << 1));
    build(mid + 1,r,(idx << 1) + 1);
}

void update(int pos,long long val,int idx) {
    if (pos == t[idx].l && pos == t[idx].r) {
        t[idx].mx = val;
        return;
    }

    int mid;

    mid = (t[idx].l + t[idx].r) >> 1;

    if (pos <= mid)
        update(pos,val,(idx << 1));
    else
        update(pos,val,(idx << 1) + 1);

    t[idx].mx = max(t[(idx << 1)].mx,t[(idx << 1) + 1].mx);
}

long long query(int l,int r,int idx) {
    if (l == t[idx].l && r == t[idx].r)
        return t[idx].mx;

    int mid;

    mid = (t[idx].l + t[idx].r) >> 1;

    if (r <= mid)
        return query(l,r,(idx << 1));
    else if (l > mid)
        return query(l,r,(idx << 1) + 1);
    else
        return max(query(l,mid,(idx << 1)),query(mid + 1,r,(idx << 1) + 1));
}

int main() {
    int N,i;
    long long ans;

    scanf("%d",&N);

    for (i = 0;i < N;i++)
        scanf("%d",&h[i]);

    for (i = 0;i < N;i++)
        scanf("%d",&a[i]);

    build(1,N,1);

    ans = 0;
    for (i = 0;i < N;i++) {
        dp[h[i]] = query(1,h[i],1) + a[i];
        ans = max(ans,dp[h[i]]);

        update(h[i],dp[h[i]],1);
    }

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

    return 0;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, K;
    std::cin >> N >> K;

    string S;
    std::cin >> S;

    vector<pair<char, int>> V(1, make_pair('0', 0));
    REP(i, N) {
        char flag = S[i];
        int  cnt  = 1;
        while(true) {
            if(S[i + 1] != flag) {
                break;
            }
            cnt++;
            i++;
            if(N - 1 <= i) {
                break;
            }
        }
        V.emplace_back(flag, cnt + V.back().second);
    }

    int ans = 0;
    for(size_t i = 1; i < V.size(); i++) {
        size_t dst = (V[i].first == '0') ? i + K * 2 - 1 :  i + K * 2;
        if(V.size() <= dst) {
            dst = V.size() - 1;
        }
        ans = max(ans, V[dst].second - V[i - 1].second);
    }

    std::cout << ans << std::endl;

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N, K;
  cin >> N >> K;
  int a;
  a = N % K;

  if(a == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;

int main(){

    ll N, M;
    cin >> N >> M;
    set<ll>S;
    S.insert(1145141919);
    vector<P>v(M);
    for(ll i = 0; i < M; i++){
        cin >> v[i].second >> v[i].first;
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    for(ll i = 0; i < M; i++){
        ll a = v[i].second;
        ll b = v[i].first;
        ll p = *S.lower_bound(a);
        if(p < b)continue;
        ans++;
        S.insert(b - 1);
    }
    cout << ans << endl;

    return 0;
}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

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

    ll n;
    cin >> n;
    n--;

    ll ans = (n + 1) * n / 2;
    cout << ans << endl;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
vector<string> a;
vector<string> b;
int n, m;
bool judge(int x,int y)
{
    bool ret = true;
    rep(i,m)
    {
        rep(j,m)
        {
            if(b[i][j]!=a[i+x][j+y])
            {
                ret = false;
            }
        }
    }
    return ret;
}
int main()
{
    cin >> n >>m;
    a.resize(n);rep(i,n)cin >> a[i];
    b.resize(m);rep(i,m)cin >> b[i];
    
    for (int dx = 0; dx+m-1 <= n-1; dx++)
    {
        for (int dy = 0; dy + m - 1 <= n - 1; dy++)
        {
            if(judge(dx,dy))
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
}

Measured memory_bytes: 3516
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    long long int N,p;
    long long int a,b;
    cin  >> N >> a >> b;
    cout << (N/(a+b))*a - max(-1*(N%(a+b)),-a) <<endl;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] a = new int[n];
    String[] str = in.readLine().split(" ");
    int[] turn = new int[n];
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
      turn[a[i]-1] = i+1;
    }
    
    for(int i=0; i<n; i++) {
      System.out.print(turn[i]);
      if(i!=n-1)
        System.out.print(" ");
    }
  }
}

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

public class Main {
    static String[][] a;
    static String temp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt(); //サイコロの個数
        a = new String[count][6];
        for (int i=0; i<count; i++) {
            for (int j=0; j<6; j++) {
                a[i][j] = sc.next();
            }
        }
        char[] c = {'E','E','E','N','W','W','W','S'};
        boolean flag = false;
        for(int i=0; i<3; i++){
            for(char e:c) {
                    shuffle(e);
                    for (int j=1; j<count; j++) {
                        if (Arrays.equals(a[0], a[j])){
                            flag=true;
                            break;
                        }
                    }
            }
        }
        if(flag) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }

    public static void shuffle(char c) {
        switch (c) {
		case 'E':
			temp = a[0][0];
			a[0][0] = a[0][3];
			a[0][3] = a[0][5];
			a[0][5] = a[0][2];
			a[0][2] = temp;
			break;
		case 'N':
			temp = a[0][0];
			a[0][0] = a[0][1];
			a[0][1] = a[0][5];
			a[0][5] = a[0][4];
			a[0][4] = temp;
			break;
		case 'W':
			temp = a[0][0];
			a[0][0] = a[0][2];
			a[0][2] = a[0][5];
			a[0][5] = a[0][3];
			a[0][3] = temp;
			break;
		default:
			temp = a[0][0];
			a[0][0] = a[0][4];
			a[0][4] = a[0][5];
			a[0][5] = a[0][1];
			a[0][1] = temp;
			break;
		}
    }
}



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

int main() {
	int n;cin>>n;
	vector<long long>v(n);
	for(int i=0;i<n;i++){cin>>v[i];}
	sort(v.begin(),v.end(),greater<long long>());
	long long res=0;
	int tot=n-2;
	res+=v[0];int ind=1;
	while(tot>0){
	    if(tot==1){res+=v[ind];}
	    else{res+=v[ind]*2;}
	    tot-=2;
	    ind++;
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 4844
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()

    flg = False
    idx_A = 0
    idx_Z = -1
    for idx, i in enumerate(s):
        if i == "A" and not flg:
            idx_A = idx
            flg = True

        if i == "Z" and flg:
            idx_Z = idx

    print(max(0, idx_Z - idx_A + 1))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 41180
n,m = map(int,input().split())

g = [[] for i in range(n+1)]
e = []

for i in range(m):
    a,b = map(int,input().split())
    e.append((a,b))
    g[a].append(b)
    g[b].append(a)

def dfs(start, end):
    q = []
    q.append(start)
    
    while q:
        cur = q.pop()
        v[cur] = 1
        
        if cur == end:
            return True
        
        for next_v in g[cur]:
            if v[next_v] != 1 and (cur, next_v) != (start, end):
                q.append(next_v)
    
    return False

ans = 0

for a,b in e:
    v = [0]*(n+1)
    if not dfs(a,b):
        ans += 1

print(ans)

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

class mint {
  uint32_t value;
  static vector<uint32_t> _fact;
  static void fill(const long n) {
    mint val = _fact.back();
    for (long i = _fact.size(); i <= n; ++i) {
      _fact.push_back(val *= i);
    }
  }

public:
  static const uint32_t MOD = 1e9 + 7;
  mint(const int64_t x)
      : value(x % MOD + (x < 0 ? MOD : 0)) {}
  operator int() const {
    return value;
  }
  mint operator+(const mint y) const {
    return mint(value + y.value);
  }
  mint &operator+=(const mint a) {
    return *this = *this + a;
  }
  mint operator*(const mint y) const {
    return mint(int64_t(value) * y.value);
  }
  mint &operator*=(const mint a) {
    return *this = *this * a;
  }
  mint operator-() const {
    return *this * mint(-1);
  }
  mint operator-(const mint y) const {
    return *this + (-y);
  }
  mint &operator-=(const mint a) {
    return *this = *this - a;
  }
  static mint fact(const long n) {
    fill(n);
    return _fact[n];
  }
  static mint pow(mint a, long n) {
    mint ans = 1;
    while (n > 0) {
      if (n & 1) ans *= a;
      a *= a;
      n >>= 1;
    }
    return ans;
  }
  mint inv() const {
    return pow(value, MOD - 2);
  }
  mint operator/(const mint y) const {
    return *this * y.inv();
  }
  static mint comb(const long n, const long k) {
    return fact(n) / fact(k) / fact(n - k);
  }
};
vector<uint32_t> mint::_fact = {1};

int main() {
  int N, K;
  string S;
  cin >> K >> S;
  N = S.size();

  mint ans = 0;
  for (int i = N - 1; i < N + K; i++) {
    ans += mint::pow(25, i - (N - 1)) * mint::pow(26, N + K - 1 - i) * mint::comb(i, N - 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 13452
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 
LL f(LL a,LL b){
    return a/b;
}


int main(){
    LL a,b,c,d;cin >> a >> b >> c >> d;
    LL n = b-a+1;
    cout << n - (f(b,c)+f(b,d)-f(b,c*d/__gcd(c,d))) + (f(a-1,c)+f(a-1,d)-f(a-1,c*d/__gcd(c,d))) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i = 0; i < (int)(n); i++)

typedef vector< vector<pair<int, int> > > Graph;
const int INF = 1<<29;
bool solve() {
  int N, M; cin>>N>>M;
  string S; cin>>S;
  vector<int> org(N+1, INF);
  vector<int> cnt(N+1, INF);
  cnt[0] = 0;
  for(int to = 1; to <= N; to++) {
    if(S[to] == '1') continue;
    for(int from = max(0, to - M); from < to; from++) {
      if(S[from] == '1') continue;
      if(cnt[from] < INF) {
	cnt[to] = cnt[from]+1;
	org[to] = from;
	break;
      }
    }
  }
  if(cnt[N] == INF) return false;
  //  cout << cnt[N] << endl;
	vector<int> ans;
	int pos = N;
	while(pos > 0) {
	  ans.push_back(pos - org[pos]);
	  pos = org[pos];
	}
	while(! ans.empty()) {
	  cout << " " << ans.back();
	  ans.pop_back();
	}
	cout << endl;

  return true;
  
}

int main() {
  bool ans = solve();
  if(ans == false) cout << -1 << endl;

  return 0;
}


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

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int N = 200005;

int a[N], n;

//your code goes there
int main()
{

        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        cin >> n;
        for(int i = 1; i <= n; ++i) cin >> a[i];
        sort(a+1,a+1+n);
        int ans = -1, Min = 1e9;
        for(int i = 1; i <= n; ++i) if(abs(a[i]-(a[n]+1)/2) < Min) Min = abs(a[i]-(a[n]+1)/2), ans = i;
        cout << a[n] << ' ' << a[ans] << endl;
        return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <cmath>
using namespace std;
using W = double;
using P = complex<W>;
constexpr W pi = acos(-1);

int main(){
  int N;
  cin >> N;
  vector<P> ps;
  for(int i = 0; i < N; ++i){
    W x, y;
    cin >> x >> y;
    ps.emplace_back(x,y);
  }
  vector<int> I(N);
  for(int i = 0; i < N; ++i) I[i] = i;
  W ans = 1e18;
  do{
    P s(0,0), d(1,0);
    W t = 0;
    for(int i = 0; i < N; ++i){
      W a = abs(arg((ps[I[i]]-s)/d));
      t += a;
      d = (ps[I[i]]-s)/abs((ps[I[i]]-s));
      s = ps[I[i]];
    }
    t += abs(arg((P(0,0)-s)/d));
    ans = min(ans,t);
  }while(next_permutation(I.begin(), I.end()));
  ans *= 180./pi;
  printf("%.12f\n",ans);
}



Measured memory_bytes: 3472
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
void print() {}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail){ cout << head << " \n"[sizeof...(tail) == 0]; print(forward<Tail>(tail)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    ll idx[100010] = {};
    rep(i,0,N){
        idx[A[i]] = i+1;
    }
    vector<ll> ans;
    rep(i,0,N){
        ans.push_back(idx[i+1]);
    }
    printa(ans, N);
    
}

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n;
	scanf("%d", &n);
	int m = (1 << n);
	multiset<int> s;
	for (int i = 0; i < m; i++) {
		int x;
		scanf("%d", &x);
		s.insert(-x);
	}

	vi done;
	done.push_back(*s.begin());
	s.erase(s.begin());

	while (done.size() < m) {
		//printf("done:"); for (auto x : done) printf(" %d", x); printf("\n");
		//printf("pool:"); for (auto x : s) printf(" %d", x); printf("\n");
		int cur = done.size();
		for (int i = 0; i < cur; i++) {
			auto it = s.upper_bound(done[i]);
			if (it == s.end()) {
				puts("No");
				return 0;
			}

			done.push_back(*it);
			s.erase(it);
		}
	}
	puts("Yes");
}


Measured memory_bytes: 13692
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)

int main() {
    ll x, y;
    cin >> x >> y;
    bool a = false;
    for(ll i = 0; i <= x; i++) {
        if (4 * i + 2 * (x - i) == y) {
            a = true;
        }
    }
    if (a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int digits[1000];
int l;

int maxim(int d)
{
    if (d > l)
        return 0;
    if (digits[d] > 0) {
        return max((l - d) * 9 + digits[d] - 1, digits[d] + maxim(d + 1));
    }
    return maxim(d + 1);
}

int main()
{
    long long a;
    cin >> a;
    while (a) {
        digits[++l] = a % 10;
        a /= 10;
    }
    reverse(digits + 1, digits + l + 1);
    cout << maxim(1) << '\n';
    return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <stdlib.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define erep(i,l,r) for((i)=(l);(i)<=(r);(i)++)
#define drep(i,l,r) for((i)=(l);(i)>=(r);(i)--)
#define MOD 1000000007
#define ll long long
using namespace std;

int main(){
    char s[100000];
    cin>>s;
    int i,n=strlen(s);
    vector<int> ans(n,0),num(2,0);

    int right;
    rep(i,0,n){
        num[i%2]++;
        if(s[i]=='R'&&s[i+1]=='L')right=i;
        else if(i==n-1||(s[i]=='L'&&s[i+1]=='R')){
            ans[right]=num[right%2];
            ans[right+1]=num[(right+1)%2];
            num[0]=0;
            num[1]=0;          
        }
    }
    rep(i,0,n)cout<<ans[i]<<" ";
    cout<<endl;
}

Measured memory_bytes: 896
import Control.Applicative
import Control.Monad
import Data.Function

main :: IO()
main = do
    n <- readLn
    plan <- replicateM n $ map read . words <$> getLine
    putStrLn $ possible plan (0,0,0)
        where
            possible [] _ = "Yes"
            possible ([t',x',y']:plan) (t,x,y)
                | d >= 0 && even d = possible plan (t',x',y')
                | otherwise = "No"
                where d = t' - t - abs (x' - x) - abs (y' - y)


Measured memory_bytes: 81276
#include <stdio.h>

int main(){
    int N=0,a,b;
    scanf("%d",&N);
    if(N==1){
        printf("Hello World\n");
        return 0;
    }
    else{
        scanf("%d %d",&a,&b);
        printf("%d\n",a+b);
        return 0;
    }
    return 0;
}


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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int k, n;

signed main()
{

    cin >> k >> n;

    vector<int> a(n);

    rep(i, n)
    {
        cin >> a[i];
    }

    int ans = a[a.size() - 1] - a[0];

    rep1(i, n)
    {
        ans = min(ans, k - a[i] + a[i - 1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nab = Array.ConvertAll(ReadLine().Split(' '), long.Parse);
        var hs = new int[nab[0]];
        for (var i = 0; i < nab[0]; i++)
            hs[i] = ToInt32(ReadLine());
        var left = 0L;
        var right = (hs.Max() + nab[2] - 1) / nab[2];
        while (right - left > 0)
        {
            var mid = (left + right) / 2;
            var ct = 0L;
            for (var i = 0; i < nab[0]; i++)
                if (mid * nab[2] < hs[i])
                    ct += (hs[i] - mid * nab[2] + nab[1] - nab[2] - 1) / (nab[1] - nab[2]);
            if (ct <= mid) right = mid;
            else left = mid+1;
        }
        WriteLine(left);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 17472
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long A;
        A = sc.nextLong();
        long B;
        B = sc.nextLong();
        solve(A, B);
    }

    static void solve(long A, long B){
        long tmp;
        while ((tmp = A % B) != 0) {
            A = B;
            B = tmp;
        }
        long ans = 1;

        if(B%2==0) {
            while(B%2==0) {
                B /= 2;
            }
            ans++;
        }

        long i = 3;
        while (i < 1000000 && B != 1) {
            if(B%i==0) {
                while(B%i==0) {
                    B /= i;
                }
                ans++;
            }
            i += 2;
        }

        if(B != 1) ans++;
        System.out.println(ans);


    }
}


Measured memory_bytes: 22608
n=int(input())
a=list(reversed(sorted(map(int,input().split()))))
i,m1,m2=1,0,0
while i<len(a):
	if a[i-1]==a[i]:
		if m1==0: 
			m1=a[i]
		elif m2==0:
			m2=a[i]
			break
		i+=1
	i+=1
print(m1*m2)

Measured memory_bytes: 62704
# -*- coding:utf-8 -*-

def solve():
    L, R = list(map(int, input().split()))
    MOD = 2019

    if R-L >= 2019:
        print(0)
        return

    L %= MOD
    R %= MOD

    ans = MOD
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min(ans, i*j%MOD)
            if ans == 0:
                print(ans)
                return
    print(ans)

if __name__ == "__main__":
    solve()


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 50;

bool op(const pair<double, string>& a, const pair<double, string>& b){
    if(a.first != b.first) return a.first > b.first;
    return a.second < b.second;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    while(1){
        int n; cin >> n;
        if(n == 0) break;
        vector<pair<double, string> > eff;
        for(int i=0;i<n;i++){
            string str;
            cin >> str;
            ll p, a, b, c, d, e, f, s, m;
            cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            double dur = (a + b + c + (d + e) * m);
            double inc = f * m * s - p;
            eff.push_back(make_pair(inc / dur, str));
        }
        sort(eff.begin(), eff.end(), op);
        for(auto ans: eff){
            cout << ans.second << endl;
        }
        cout << '#' << endl;
    }
}


Measured memory_bytes: 3036
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
int n,a[100010],x;
int main(){
	//freopen("xxx.in","r",stdin);
	splay(n);
	for(int i=1;i<=n;i++){
		splay(a[i]);		
	}
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--){
		if(a[i]==a[i-1]){
			if(!x)x=a[i];
			else cout<<(long long)x*a[i]<<endl,exit(0);
			i--;
		}
	}
	cout<<0<<endl;
}

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

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	// dp[i] - TRUE if the first player wins if there are i stones left
	vector<bool> dp(k + 1, false);
	for (int stones = 0; stones <= k; stones++) {
		for (int x : a) {
			if (stones >= x && !dp[stones - x]) {
				dp[stones] = true;
			}
		}
	}
	/*
	for(int i=0; i<=k; i++) {
	    cout << dp[i] << " ";
	}
	cout << endl;
	*/
	cout << (dp[k] ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 256
def foa(a,count):
    b = a[:]
    for i in range(len(b)):
        b[i] = a.count(a[i])
    if b == a:
        print count
        print " ".join(map(str, b))
        return
    else:
        return foa(b,count+1)

while True:
    n = int(raw_input())
    if n == 0:
        break
    a = map(int, raw_input().split())
    foa(a,0)

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

int main() {
    int h,n;
    cin>>h>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a.at(i);
    int p=0;
    for(int i=0;i<n;i++)p+=a.at(i);
    if(p>=h) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 640
N, M, C = map(int, input().split())
B = list(map(int, input().split())) 
A = [list(map(int, input().split())) for i in range(N)]

cnt = 0

for i in range(N):
  total = C
  for j in range(M):
    total +=A[i][j]*B[j]
  if total >0:
    cnt+=1
print(cnt)

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio
  ll n,i,j,k;
  cin >> n;
  vl a(n);
  uml f;
  forn(0,n,i){
    cin >> a[i];
    f[a[i]]++;
  }
  ll mx = *max_element(all(a));

  if(f[mx] > 1){
    forn(0,n,i){
      cout << mx << '\n';
    }
  }else{
    ll mx2 = 0;
    forn(0,n,i){
      if(a[i] != mx){
        mx2 = max(mx2, a[i]);
      }
    }
    forn(0,n,i){
      if(a[i] == mx){
        cout << mx2 << '\n';
      }else{
        cout << mx << '\n';
      }
    }
  }

  ktj();
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    
    const int nmmax = 50;
    char a[nmmax][nmmax], b[nmmax][nmmax];

    rep(y, n) {
        rep(x, n) {
            cin >> a[y][x];
        }
    }

    rep(y, m) {
        rep(x, m) {
            cin >> b[y][x];
        }
    }

    bool exist = false;

    rep(ly, n) {
        rep(lx, n) {
            if(ly + m - 1 >= n || lx + m - 1 >= n) continue;

            bool match = true;
            rep(y, m) {
                rep(x, m) {
                    if(a[ly + y][lx + x] != b[y][x]) match = false;
                }
            }
            if(match) exist = true;
        }
    }

    if(exist) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

int N, C;
vector<pii> v[30], v2[30];
int cum[200010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> C;
  for (int i = 0; i < N; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    v[c - 1].emplace_back(s, t);
  }
  for (int i = 0; i < C; i++) {
    sort(v[i].begin(), v[i].end());
    int l = 0, r = 0;
    while (l < v[i].size()) {
      while (r + 1 < v[i].size() && v[i][r].second == v[i][r + 1].first) r++;
      v2[i].emplace_back(v[i][l].first, v[i][r].second);
      l = ++r;
    }
  }
  for (int i = 0; i < C; i++) {
    for (pii &p : v2[i]) {
      cum[p.first * 2 - 1]++;
      cum[p.second * 2]--;
    }
  }
  int ans = cum[0];
  for (int i = 1; i < 200010; i++) {
    cum[i] += cum[i - 1];
    ans = max(ans, cum[i]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3200
#include<iostream>
using namespace std;
int main()
{
	int a,j,b,n,i;
	cin>>n;
	for(i=1;i<10;i++)
	{
	for(j=1;j<10;j++)
	{	
	if(i*j!=n)
	{
       continue;
	}
	else if(i*j==n)
	{
	cout<<"Yes";
	return 0;
	}
	}
	
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		while(true){
			int h = sc.nextInt();
			if(h==0) break;
			Integer[][] map = new Integer[5][h];

			for(int i=0; i<h; i++){
				for(int j=0; j<5; j++){
					map[j][i] = sc.nextInt();
				}
			}

			System.out.println(chainDisappearance(map));
		}
	}

	public static int chainDisappearance(Integer[][] map){
		int score = 0;
		boolean flag = false;
		
		for(int i=map[0].length-1; i>=0; i--){
			if(map[2][i]==0) break;
			if(map[2][i]==map[1][i]){
				if(map[2][i]==map[3][i]){
					score += map[2][i]*3;
					flag = true;
					if(map[2][i]==map[0][i]){
						score += map[2][i];
						map[0][i] = 0;
					}
					if(map[2][i]==map[4][i]){
						score += map[2][i];
						map[4][i] = 0;
					}
					map[1][i] = 0;
					map[2][i] = 0;
					map[3][i] = 0;
				}else{
					if(map[2][i]==map[0][i]){
						score += map[2][i]*3;
						map[2][i] = 0;
						map[1][i] = 0;
						map[0][i] = 0;
						flag = true;
					}
				}
			}else{
				if(map[2][i]==map[3][i] && map[2][i]==map[4][i]){
					score += map[2][i]*3;
					map[2][i] = 0;
					map[3][i] = 0;
					map[4][i] = 0;
					flag = true;
				}
			}
		}

		if(flag){
			for(int i=0; i<5; i++){
				Arrays.sort(map[i], new Comparator<Integer>(){
					public int compare(Integer a, Integer b){
						int temp = 0;
						if(a==0 && b>0) temp = -1;
						return temp;
					}
				});
			}
			score += chainDisappearance(map);
		}

		return score;
	}
}

Measured memory_bytes: 56312
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;cin>>s;
	int res=0,ans=0;
	if(s[0]=='A'){
		for(int i=2;i<s.length()-1;i++){
			if(s[i]=='C')ans++;
		}
		if(ans!=1){cout<<"WA"<<endl;return 0;}
		for(int i=0;i<s.length();i++){
			if(s[i]>='a'&&s[i]<='z'){
				res++;
			}
		}
		if(res!=s.length()-2){cout<<"WA"<<endl;return 0;}
	}else{cout<<"WA"<<endl;return 0;}
	cout<<"AC"<<endl;
}

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

using namespace std;
typedef long long ll;

#define INF (1e9)

int main(int argc, const char *argv[])
{
    ll N, K, a, b;
    cin >> N >> K;

    vector<pair<ll, ll> > v;
    for (ll i = 0; i < N; i++)
    {
        cin >> a >> b;
        v.push_back(pair<ll, ll>(a, b));
    }

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

    for (ll i = 0; i < v.size(); i++)
    {
        K -= v[i].second;
        if (K <= 0)
        {
            cout << v[i].first << endl;
            break;
        }
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }

  int ans=0;

  for(int i=0; i<N; i++){
    if((i+1+1)%2==0 && (a.at(i)+1)%2==0){
      ans++;
    }
  }

  cout << ans << endl;

return 0;
}


Measured memory_bytes: 3624
# coding: utf-8
# Your code here!

N = int(input())
C = []

prev = -1

for _ in range(N):
    tmp = int(input())
    if tmp != prev:
        C.append(tmp)
    prev = tmp

dp = [0]*(len(C)+1)
place = {}
dp[0] = 1

for i in range(len(C)):
    if place.get(C[i]) != None:
        dp[i+1] = dp[i] + dp[place.get(C[i])]
    else:
        dp[i+1] = dp[i]
    place[C[i]] = i+1
    
print(dp[-1]%(10**9+7))

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

int main(){
  string N;
  cin >> N;
  vector<string> vec = {"7", "5", "3"};
  queue<string> Q;
  for(int i=0; i<3; i++){
    Q.push(vec.at(i));
  }
  
  vector<int64_t> num(0);

  for(int i=0; i<N.size(); i++){
    int cnt = Q.size();
    int k = 0;
    bool end = true;
    while(k < cnt){
      string S = Q.front();
      Q.pop();
      for(int j=0; j<3; j++){
        string T = S;
        T += vec.at(j);
        if(T.size() >= 3 && T.size() <= N.size()){
          int pos3 = T.find("3");
          int pos5 = T.find("5");
          int pos7 = T.find("7");
          if(pos3 >= 0 && pos5 >= 0 && pos7 >= 0){
            int x = stoi(T);
            num.push_back(x);
          }
        }
        Q.push(T);
      }
      k++;
    }
  }
  
  sort(num.begin(),num.end());
  int y = stoi(N);
  auto position = upper_bound(num.begin(),num.end(),y);
  int place = distance(num.begin(),position);
  cout << place << endl;
  
}

Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator& itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator& begin() {return i;}
  Iterator& end() {return n;}
};

template<class T> inline T at(const vector<T> &v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

template<class T> inline bool is_max(T &a, const T &b) {return a < b ? a = b, true : false;}
template<class T> inline bool is_min(T &a, const T &b) {return a > b ? a = b, true : false;}

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    vector<int> p;
    for (int _ : range(n)) {
      int x;
      cin >> x;
      p.emplace_back(x);
    }
    p.emplace_back(0);
    vector<int> s;
    for (int i : p) for (int j : p) s.emplace_back(i + j);
    int res = 0;
    int i = 0, j = s.size() - 1;
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
    while (i <= j) {
      if (s[i] + s[j] > m) {
        --j;
        continue;
      }
      is_max(res, s[i] + s[j]);
      ++i;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 9196
import sys
sys.setrecursionlimit(4100000)

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    N = [int(x) for x in sys.stdin.readline().split()][0]
    edge_list = [[] for _ in range(N)]

    for _ in range(N-1):
        u, v, w = [int(x) for x in sys.stdin.readline().split()]
        edge_list[u-1].append((v-1, w))
        edge_list[v-1].append((u-1, w))

    color_list = [0] * N
    visited_set = set()
    def dfs(i_rec, c_rec):
        visited_set.add(i_rec)
        color_list[i_rec] = c_rec
        for i_next, weight in edge_list[i_rec]:
            if i_next in visited_set:
                continue
            if weight % 2 == 0:
                dfs(i_next, c_rec)
            else:
                dfs(i_next, 1 - c_rec)

    dfs(0, 0)

    for c in color_list:
        print(c)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
1 2 2
2 3 1"""
        output = """0
0
1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """5
2 5 2
2 3 10
1 3 8
3 4 2"""
        output = """1
0
1
0
1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1"""
        output = """0"""
        self.assertIO(input, output)


Measured memory_bytes: 95600
#include <iostream>

using namespace std;

int main(){
    int a,b,count = 0;
    cin >> a >> b;

    for(int i = 0;i < 2;i++){
        if(a > b){
            count += a;
            a--;
        }else{
            count += b;
            b--;
        }
    }

    cout << count << endl;

    return 0;
}

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

int main(int argc, const char * argv[]) {
  vector<int> n(3);
  int k;
  cin >> n.at(0);
  cin >> n.at(1);
  cin >> n.at(2);
  cin >> k;
  sort(n.begin(), n.end());
  cout << n.at(0) + n.at(1) + n.at(2) * pow(2,k) << endl;

  return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))

NA = set(A)
d = {x:0 for x in NA}

for i in range(N):
    d[A[i]] += 1

counter = 0
for p in d:
    if p > d[p]:
        counter += d[p]
    else:
        counter += d[p]-p

print(counter)

Measured memory_bytes: 23412
N,H,W = map(int, input().split())
c=0
for _ in  range(N):
    try:
        listA=list(map(int,input().split()))
        A,B = listA[0], listA[1]
        
        if H <= A and W <= B:
            c+=1
    except:
        break;
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
using namespace std;


int main(void) {
    int N, M;
    cin >> N >> M;
    priority_queue<long> A;
    for(int i = 0; i < N; i++) {
        long a;
        cin >> a;
        A.push(a);
    }
    for(int i = 0; i < M; i++) {
        long max = A.top();
        A.pop();
        A.push(max / 2);
    }
    long ans = 0;
    while(!A.empty()) {
        ans += A.top();
        A.pop();
    }
    cout << ans << endl;
    return 0; 
}

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


import static java.lang.System.in;

class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int K = Integer.parseInt(reader.readLine());
        char[] ar = reader.readLine().toCharArray();
        if(ar.length<=K) System.out.println(new String(ar));
        else{
            String res="";
            for (int i = 0; i <K ; i++) {
                res=res+ar[i]+"";
            }
            res=res+"...";
            System.out.println(res);
        }
    }
}


Measured memory_bytes: 37248
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

string red[105] ,blue[105];

int main()
{
	int n,m;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) cin >> blue[i];
	scanf("%d", &m);
	for(int i = 0; i < m; i++) cin >> red[i];
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		int num = 0;
		for(int j = 0; j < n; j++)
		{
			if(blue[i] == blue[j]) num++;
		}
		for(int j = 0; j < m; j++)
		{
			if(blue[i] == red[j]) num--;
		}
		ans = max(ans, num);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
N = int(input())
route = [ int(it)-1 for it in input().split() ]

if (True):
    c = 0
    for i in range(N-1):
        if route[i] == i:
            route[i],route[i+1]=route[i+1],route[i]
            c += 1
    if (route[N-1]==N-1):
        i = N-2
        route[i],route[i+1]=route[i+1],route[i]
        c += 1
    print (c)

Measured memory_bytes: 52332
#include <iostream>
#include <cstring>
#include <vector>
#include <iomanip>
using namespace std;

struct Edge {
    int to, cost;
};

const int MAX_N = 100010;

double table[MAX_N];
bool used[MAX_N];

double p, expectation;
int n;

vector<Edge> graph[MAX_N];

double calc_expectation(int v, int par) {
    if (used[v]) return table[v];
    used[v] = true;

    double val = 0.0;

    for (Edge e : graph[v]) {
        if (e.to == par) continue;
        else val += p * (e.cost + calc_expectation(e.to, v));
    }
    return val;
}

double calc_expectation2(int v, int par) {
    if (used[v]) return table[v];
    used[v] = true;

    double val = expectation;

    for (Edge e : graph[v]) {
        if (e.to == par) continue;
        else val += p * (e.cost + calc_expectation2(e.to, v));
    }
    return val;
}

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

    for (int i = 0; i < n - 1; i++) {
        int x, y, c;
        cin >> x >> y >> c;

        x--; y--;

        graph[x].push_back((Edge){y, c});
        graph[y].push_back((Edge){x, c});
    }

    expectation = calc_expectation(0, -1);

    memset(used, false, sizeof(used));
    cout << fixed << setprecision(10) << calc_expectation2(0, -1) << endl;

    return 0;
}

Measured memory_bytes: 15016
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,p,q=36,x;
  cin >> N;
  for(int i=0;i<N;i++){
 	cin >> x;
    p = 0;
    while(true){
      if(x%2==0){
        p++;
        x/=2;
      }
      else
      break;
    }
    if(p<q)
      q=p;
  }
  cout << q << endl;
}

Measured memory_bytes: 256