akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		int k[] = new int[m];
		ArrayList<ArrayList<Integer>> list = new ArrayList<>();
		for (int i = 0; i < m; i++) {
			list.add(new ArrayList<>());
		}

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");

			k[i] = Integer.parseInt(str[0]);

			for (int j = 1; j <= k[i]; j++) {
				list.get(i).add(Integer.parseInt(str[j]));
			}
		}

		int p[] = new int[m];
		str = br.readLine().split(" ");

		for (int i = 0; i < m; i++) {
			p[i] = Integer.parseInt(str[i]);
		}

		List<String> com = conbination(Arrays.asList(""), n);

		int ans = 0;
		for (int i = 0; i < com.size(); i++) {
			String swit[] = com.get(i).split("");
			boolean flag = false;

			for (int j = 0; j < m; j++) {
				int count = 0;
				for (int l = 0; l < k[j]; l++) {
					if (swit[list.get(j).get(l) - 1].equals("1")) {
						count++;
					}
				}

				if (p[j] == 0) {
					if (count % 2 == 0) {
					} else {
						flag = true;
					}
				} else {
					if (count % 2 == 0) {
						flag = true;
					}
				}
				if (flag) {
					break;
				}
			}
			if (!flag)
				ans++;
		}
		System.out.println(ans);
	}

	public static List<String> conbination(List<String> binary, int count) {
		if (count <= 0)
			return binary;
		List<String> list = new ArrayList<String>(binary.size() * 2);
		for (String s : binary) {
			list.add(s + 0);
			list.add(s + 1);
		}
		return conbination(list, count - 1);
	}
}


Measured memory_bytes: 26452
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(void)
{
    string a, b;
    cin >> a >> b;
    int n = stoi(a + b);
    bool is_sq = false;
    for(int i = 0; i < 1000; ++i)
    {
        int p = pow(i, 2);
        if(n == p)
        {
            is_sq = true;
            break;
        }
        else if(n < p)
        {
            break;
        }
    }
    cout << (is_sq ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 888
#AGC024-B Backfront
"""
ある一要素を選んで数列の先頭もしくは最後尾に移動させる。
これを繰り返して昇順に並び替えるときの最小手数
解法：
O(N)で求める必要があるので、シュミレーション的な解法ではない。
増加部分列のうち、その増加分が1である制約を加えた場合の
部分列の長さをlとした時、
n-lが答え。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n = int(readline())
lst1 = []
for i in range(n):
    lst1.append(int(readline())-1)

lst2 = [0]*n
for i in range(n):
    lst2[lst1[i]] = i
#print(lst1)
#print(lst2)

ans = 0
res = 1
for i in range(1,n):
    if lst2[i] > lst2[i-1]:
        res += 1
    else:
        ans = max(ans,res)
        res = 1

ans = max(ans,res)
print(n-ans)

Measured memory_bytes: 47156
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main()
{ 

string s;
cin>>s;
int n=s.length();
for(ll i=0;i<n;i++)
{
    if(s[i]=='?')
    {
      
       s[i]='D';
    }
}

cout<<s;

    return 0;
}


Measured memory_bytes: 3748
v,e = map(int, input().split())
adj = [list(map(int, input().split())) for i in range(e)]
adj.sort(key = lambda x:x[2])
group = [[i] for i in range(v)]
key = [i for i in range(v)]
sum = 0
for i,j,k in adj:
    if key[i] != key[j]:
        h = key[j]
        group[key[i]] += group[h]
        sum += k
        for t in group[h]:
            key[t] = key[i]
        group[h] = []
        if len(group[key[i]]) == v:
            break
print(sum)


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

public class Main {

    /**
     *
     * k = 1
     *
     * 2^17+1  2^17     0
     * 1      2^17+1   1
     *
     * dp[2][2] = max(
     */

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n-1; i++) {
            int lead = sc.nextInt();
            map.put(lead, map.getOrDefault(lead, 0 ) + 1);
        }
        for (int i = 0; i < n; i++) {
            if (map.containsKey(i + 1)) {
                System.out.println(map.get(i+1));
            } else {
                System.out.println(0);
            }
        }

    }

    private static void solve(int[] ans, int n, int[] arr) {

    }

    /**\
     *
     * 4
     * 2 3 4 5
     *
     *
     * 1 2 3 4 5 6 7 8
     * 2 6 3 7 4 8 5 9
     */

    // 1 1 1 0 0 0
    // 0 0 1 1 1 1


    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

/**
 * 7 3
 * 3 1 5
 * 9 6 5
 *
 * i = 1: 1
 * i = 2: 2
 * i = 3: 3
 *
 *
 * 1 2 3 3 3 3 3
 */


/**
 *
 *  1+1
 **/

Measured memory_bytes: 68900
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#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 vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];

    sort(all(h));

    int ans = INT_MAX;
    for (int i = 0; i < n-k+1; i++){
        ans = min(ans, abs(h[i] - h[i+k-1]));
    }

    cout << ans << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

int a[200007];

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

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

	int d = 0;
	for(int i = 1; i <= n; i++){
		
		int x = a[i%n] - a[(i-1)%n];
		if(i-1 == n-1){
			x = k - a[i-1] + a[i%n];
		}
		if(x >= d){
			d = x;
		}
		//~ cout<<i%n<<" "<<(i-1)%n<<":"<<x<<endl;
	}
	
	cout<<k - d;
	
    return 0;
}
	


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

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

int main(void)
{
    string s;
    cin >> s;
    int n = s.size();

    v_int ans(n);

    int r_cnt = 0;
    irep(i, n-1) {
        if(s[i] == 'R') {
            r_cnt++;
        } 
        if(s[i] == 'R' && s[i+1] == 'L') { 
            ans[i] += (r_cnt+1)/2;
            ans[i+1] += r_cnt/2;
            r_cnt = 0;
        }
    }

    int l_cnt = 0;
    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());

    irep(i, n-1) {
        if(s[i] == 'L') {
            l_cnt++;
        } 
        if(s[i] == 'L' && s[i+1] == 'R') { 
            ans[i] += (l_cnt+1)/2;
            ans[i+1] += l_cnt/2;
            l_cnt = 0;
        }
    }
    reverse(ans.begin(), ans.end());
    irep(i, n) {
        printf("%d ", ans[i]);
    }
    return 0;
} /*atcoder*/



Measured memory_bytes: 3896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int N=1e5+10, M=(ll)1e9+1 ;
const int mod = 1e9+7  ;

void work(){
   ll n,l;
   cin >> n >> l;
   vl a(n+1);
   for(ll i=1;i<=n;i++)
        a[i]=l+i-1;
    ll mi,x,s=0;
    mi=INT_MAX;
   for(ll i=1;i<=n;i++){
        s+=a[i];
        if(mi>abs(a[i])){
            mi=abs(a[i]);
            x=a[i];
        }

   }
   cout << s-x;
}
int main(){
 ios_base::sync_with_stdio(0);

    ll t,z;
    // cin >> t;
    // z=t;
    t=1;
    while(t--){
            // cout << "Case #" << z-t << ": ";
            work();
    }
   return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
template<class T>using vv = vector<vector<T>>;
using vvi = vv<int>;
using vvl = vv<long long>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define repi(i,a,b) for(int i=(a),_i=(b);i<_i;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif

int N;
vv<int> A;
ll dp[1<<16][16];
const ll INF = 1e15;
ll dfs(int used, int i) {
  if (i == N)
    return 0;

  if (dp[used][i] != INF)
    return dp[used][i];

  if (used & (1 << i))
    return dfs(used, i+1);

  ll ans = 0;

  vi notUsed;
  rep(j, N)
    if (!(used & (1 << j))) {
      if (j < i)
        return -INF;
      notUsed.push_back(j);
    }

  rep(bit, 1 << (notUsed.size())) {
    ll tmp = 0;
    int used2 = 0;
    rep(j, notUsed.size()) {
      if (bit & (1 << j)) {
        used2 |= 1 << notUsed[j];
        rep(k, j+1, notUsed.size()) {
          if (bit & (1 << k))
            tmp += A[notUsed[j]][notUsed[k]];
        }
      }
    }
    ans = max(ans, tmp + dfs(used | used2, i+1));
  }
  return dp[used][i] = ans;
}
int main() {
  in(N);
  A.resize(N, vector<int>(N, 0));

  rep(i, 1<<16) rep(j, 16) dp[i][j] = INF;
  rep(i, N) rep(j, N) {
    cin >> A[i][j];
  }
  cout << dfs(0, 0) << endl;

  return 0;
}


Measured memory_bytes: 8448
N,K=[int(i) for i in input().split()]
S=input()
cur=0
line=[]

for i in range(len(S)):
	if i==0:
		if S[0]=="0":
			line.append(0)
		line.append(1)
	else:
		if S[i-1]!=S[i]:
			line.append(1)
		else:
			line[-1]+=1
c=0
for i in range(len(line)):

	if i==0:
		if i+2*K+1<=len(line):
			s=sum(line[i:2*K+1])
			c=s
		else:
			s=sum(line[i:])
			c=s
	elif i%2==0:
		if i+2*K+1<=len(line):
			s=s-line[i-2]-line[i-1]+line[i+2*K-1]+line[i+2*K]
			c=max(c,s)
		else:
			c=max(c,sum(line[i:]))
			break
print(c)

Measured memory_bytes: 4560
import sys
import math
s = int(sys.stdin.readline().rstrip("\n"))
h = 10**9 + 7
ans = 0
n = 1
while s-3*n >= 0:
    a = math.factorial(s-2*n-1) % h
    b = math.factorial(s-3*n) * math.factorial(n-1)
    c = pow(b,h-2,h)
    ans = ans + a*c%h
    ans = ans % h
    n += 1
print(ans)

Measured memory_bytes: 79380
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int N = IntRead();
        int H = IntRead();
        int W = IntRead();
        Console.WriteLine((N-H+1)*(N-W+1));
    }
}

public class AtCoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int GCD(int a, int b)
    {
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(int a, int b)
    {
        return (long)a * b / GCD(a, b);
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static long[] LSRead()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static long Combination(int n, int r)
    {
        if (n == r || r == 0) return 1;
        return
            Enumerable.Range((n - r + 1), r).ToList().Aggregate((now, next) => now * next) /
            Enumerable.Range(1, r).ToList().Aggregate((now, next) => now * next);
    }
    public static long Permutation(int n, int r)
    {
        if (n == r) return 1;
        return
            Enumerable.Range((n - r), r).ToList().Aggregate((now, next) => now * next);
    }
    public static long RepPow(long x, long p, long m = 1000000007)
    {
        if (p == 1) return x % m;
        long b = RepPow(x, p / 2, m) % m;
        if (p % 2 == 0) { return (b * b) % m; }
        else { return (x * ((b * b) % m)) % m; }
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;
            public class Main{
            public static void main(String[] args){
            	Scanner scan  = new Scanner(System.in);
            	int n = scan.nextInt();
              	switch(n%10){
                  case 2:
                  case 4:
                  case 5: 
                  case 7:
                  case 9:
                    System.out.println("hon");
                    break;
                  case 0:
                  case 1:
                  case 6:
                  case 8:
                          System.out.println("pon");
                          break;
                  case 3:
                    System.out.println("bon");
                    break;
                }
              
              
            }
            }

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

A.sort(reverse = True)
ans = A[0]
count = 1
flg = False

if N == 2:
    print(ans)
    exit()
    
for i in range(1,N):
    for j in range(2):
        ans += A[i]
        count += 1
        if count >= N-1:
            flg = True
            break
    if flg == True:
            break
        
print(ans)

Measured memory_bytes: 31440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (ll i = (a); i < (n); i += (s))
#define rep(...) _overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    ll n; cin >> n;
    ll n_0 = 0;
    vi h(n);
    rep(i,n) {
        ll a;
        cin >> a;
        h[i] = a;
        if (a == 0) ++n_0;
    }
    ll cnt = 0;
    while (n_0 != n) {
        ll argma = max_element(all(h)) - h.begin();
        ll left = 0, right = n - 1;
        rep(i, 0, argma + 1) {
            ll j = argma - i;
            if (h[j] == 0) {
                left = j + 1;
                break;
            }
        }
        rep(i, argma, n) {
            if (h[i] == 0) {
                right = i - 1;
                break;
            }
        }
        ll mi = INF;
        rep(i, left, right + 1) {
            chmin(mi, h[i]);
        }
        rep(i, left, right + 1) {
            h[i] -= mi;
            if (h[i] == 0) ++n_0;
        }
        cnt += mi;
    }
    print(cnt);
}

Measured memory_bytes: 3612
import math
#import itertools
#import statistics
#import numpy as np
import collections
n = int(input())
#a = list(map(int, input().split()))
#a = list(map(int, input().split()))
k = int(input())
x = list(map(int, input().split()))
total = 0
for i in range(n):
    if k-x[i] >= x[i]:
        total += x[i]*2
    else:
        total += (k-x[i])*2
print(total)



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

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  double ans = 0.;
  for(int i=1;i<=n;i++){
    int p = i;
    double q = 1. / n;
    while(p < k){
      p *= 2;
      q *= 0.5;
    }
    ans += q;
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MIN(x, y) ((x) < (y) ? (x) : (y))
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}

int mcm(int *first, const int N) {
    int dp[N][N];
    for(int i = 0; i < N; ++i)
        for(int j = 0; j < N; ++j) dp[i][j] = 1 << 28;
    for(int i = 0; i < N; ++i) dp[i][i] = 0;
    for(int l = 0; l < N; ++l)
        for(int i = 0; i < N - l; ++i) {
            int j = i + l;
            for(int k = i; k < j; ++k)
                dp[i][j] = MIN(dp[i][j], dp[i][k] + dp[k + 1][j] + first[i] * first[k + 1] * first[j + 1]);
        }
    return dp[0][N - 1];
}
int main(int argc, char **argv) {
    int n = get_uint();
    int m[n + 1];
    for(int i = 0; i < n; ++i) m[i] = get_uint(), m[i + 1] = get_uint();
    put_uint(mcm(m, n));
    putchar_unlocked('\n');
    return 0;
}



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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  if((A+B)>(C+D)){
    cout<<"Left"<<endl;
  }
  else if((A+B)==(C+D)){
    cout<<"Balanced"<<endl;
  }
  else{cout<<"Right"<<endl;
      }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;

int n,m;
int dp[100005] = {0};
int in[100005] = {0};

int ec = 0,hed[100005] = {0},to[100005],nxt[100005];
void add_edge(int f,int t){
	in[t] ++;
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec;
}

queue <int> q;
void tpsort(){
	for(int i = 1;i <= n;i ++){
		if(!in[i]) q.push(i);
	}
	while(!q.empty()){
		int u = q.front(); q.pop();
		for(int i = hed[u];i;i = nxt[i]){
			int v = to[i];
			dp[v] = max(dp[v],dp[u] + 1);
			in[v] --;
			if(!in[v]) q.push(v);
		}
	}
}

int main(){
	int a,b;
	scanf("%d %d",&n,&m);
	while(m --){
		scanf("%d %d",&a,&b);
		add_edge(a,b);
	}
	tpsort();
	int ans = 0;
	for(int i = 1;i <= n;i ++) ans = max(ans,dp[i]);
	printf("%d\n",ans);
	return 0;
}
//

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

using namespace std;

#define ll long long
#define ar array

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

       int n[a];


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

           if(n[i]>=b) sum++;

       }

          // cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[2]<<" "<<endl;
           cout<<sum<<endl;


    }



Measured memory_bytes: 640
function Main(input) {
	const col = input.split("\n");
	const N = parseInt(col[0], 10);
	let row = col[1].split(" ");
	for(let s=0; s < row.length; s++){
		row[s] = parseInt(row[s], 10);
	}
	let tmp = row[0];
	let cnt = 0;
	if(row.length > 1){
		for(let i = 1; i < row.length; i++){
			if(tmp > row[i]){
				cnt += tmp - row[i];
			} else {
				tmp = row[i];
			}
		}
	}
	console.log(cnt);
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 48972
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
const int MAXM = 4e2 + 5;
const int MAXN = 26 + 5;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;

int n=26, m;
int c[MAXN];
int a[MAXM][MAXN];

int p[MAXM];
set<int> idx[MAXN];
int ans;

void init(void)
{
	for(int i=1; i<=n; ++i)
	{
		idx[i].clear();
		idx[i].insert(0);
		idx[i].insert(m+1);
	}
	
	for(int k=1; k<=m; ++k)
		idx[ p[k] ].insert(k);
}

int recalc(register int pos, register int x)
{
	register int old = p[pos];
	if(old == x) return ans;
	
	register int res = ans;
	
	idx[old].erase(pos);
	
	set<int>::iterator it = idx[old].upper_bound(pos);
	register int nxt = *it;
	register int lst = *(--it);
	
	res -= (pos - lst) * c[old] * (nxt - pos) + a[pos][old];
	
	it = idx[x].upper_bound(pos);
	nxt = *it;
	lst = *(--it);
	
	res += (pos - lst) * c[x] * (nxt - pos) + a[pos][x];
	
	idx[x].insert(pos);
	
	p[pos] = x;
	return res;
}

int main(void)
{
	srand(time(0));
	
	scanf("%d",&m);
	for(int i=1; i<=n; ++i) scanf("%d",&c[i]);
	for(int i=1; i<=m; ++i)
		for(int j=1; j<=n; ++j)
			scanf("%d",&a[i][j]);
	
	static int lst[MAXN];
	
	ans = 0;
	for(int k=1; k<=m; ++k)
	{
		int mx = -inf;
		int mxi = -1;
		for(int i=1; i<=n; ++i)
		{
			int res = a[k][i];
			for(int j=1; j<=n; ++j) if(j!=i)
				res -= c[j] * (k-lst[j]);
			
			if(mxi==-1 || mx < res)
				mxi = i, mx = res;
		}
		lst[mxi] = k;
		
		ans += mx;
		p[k] = mxi;
	}
	
	init();
	
	static int pp[MAXM];
	static int qq[MAXM];
	
	for(int i=1; i<=m; ++i) pp[i] = i;
	for(int i=1; i<=n; ++i) qq[i] = i;
	
	register int T = 50;
	while(T--)
	{
		random_shuffle(pp+1,pp+m+1);
		random_shuffle(qq+1,qq+n+1);
		
		for(int i=1; i<=m; ++i)
			for(int j=1; j<=n; ++j)
			{
				int pos = pp[i];
				int x = qq[j];
				
				int old = p[pos];
				int res = recalc(pos, x);
				if(res < ans) recalc(pos, old);
				else ans = res;
			}
	}
	
	for(int i=1; i<=m; ++i) printf("%d\n",p[i]);
	return 0;
}

Measured memory_bytes: 3388
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
 
    const lines = input.split('\n')
    const N = lines[0] - 0
    const A = lines[1].split(' ').map(Number)

    let c = Array(N).fill(0)

    for (let i = 0; i < A.length; i++) {
        c[A[i] - 1]++
    }

    console.log(c.join("\n"))

})(input)


Measured memory_bytes: 53432
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#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
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   cout << ((n+1000-1)/1000)*1000-n;
   return 0;
} 

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define all(x) (x).begin(), (x).end()
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
    

    return 0;
}


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

using namespace std;

int main() {
    int N, x;
    cin >> N >> x;
    vector<int>a(N);
    for (int &i:a) cin >> i;
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (x >=a.at(i)) {
            ans++;
            x-=a.at(i);
        }
    }
    if (ans ==N&& x >0) ans--;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

const ll N=2e5+5;
ll n,m,top,a[N],fst[N],lst[N],nxt[N],vis[N],s[N],k;

int main() {
  cin >> n >> k;
  for(ll i=1;i<=n;i++) {
    cin >> a[i];
    if(!fst[a[i]]) fst[a[i]]=i;
  }
  nxt[n+1]=1;
  for(ll i=n;i;i--) {
    if(!lst[a[i]]) nxt[i]=fst[a[i]]+1; 
    else nxt[i]=nxt[lst[a[i]]+1];
    lst[a[i]]=i;
  }
  for(ll i=1;!vis[i];i=nxt[i]) {
    vis[i]=1;
    s[++m]=i;
  }
  memset(vis,0,sizeof(vis));
  for(ll i=s[(k-1)%m+1];i<=n;i++) {
    if(!vis[a[i]])s[++top]=a[i],vis[a[i]]=1;
    else {
      do{
        vis[s[top--]]=0;
      } while(s[top+1]!=a[i]);
    }
  }
  for(ll i=1;i<=top;i++) {
    if(i!=1) cout << " ";
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 10880
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
ans=0
for i in range(2**N):
    a=[]
    flag=0
    for j in range(N):
        if (i>>j)&1:
            a.append(j+1)
    for k in range(M):
        cnt=0
        for l in range(A[k][0]):
            if A[k][l+1] in a:
                cnt+=1
        if cnt%2!=p[k]:
            flag=1
    if flag==0:
        ans+=1
    
print(ans)


Measured memory_bytes: 74336
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
#define mod (int)(1000000007)
using namespace std;
int test[213456]; string uiop[213456];
signed main() {
	int n, a, b = 0, c = 1234567890, ans = 0; string s; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a; ans += abs(a); c = min(c, abs(a));
		if (a < 0) { b++; }
	}
	if (b % 2 == 0) { cout << ans << endl; }
	else { cout << ans - c - c << endl; }
}

Measured memory_bytes: 1920
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
#define maxn 100010
int a[maxn],b[maxn];
int main(int argc, char const *argv[])
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for(int i=1;i<=n;i++)
        {
            int a1;
            scanf("%d",&a1);
            if(i%2) a[a1]++;
            else b[a1]++;
        }
        int ansa=0,ansb=0;
        int fa=0,fb=0;
        for(int i=1;i<maxn;i++)
        {
            if(a[i]>ansa)
            {
                ansa=a[i];
                fa=i;
            }
            if(b[i]>ansb)
            {
                ansb=b[i];
                fb=i;
            }
        }
        int ans=ansa+ansb;
        int ea=0,eb=0;
        int ans1a=0,ans1b=0;
        if(fa==fb)
        {
            for(int i=1;i<maxn;i++)
            {
                if(a[i]>ans1a&&i!=fa)
                    ans1a=a[i];
                if(b[i]>ans1b&&i!=fb)
                    ans1b=b[i];
            }
            ans=max(ansa+ans1b,ansb+ans1a);
        }
        printf("%d\n",n-ans);
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int x,y;
  cin>>x>>y;
  cout<<x+(y/2)<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3532
#!/usr/bin/env python3

def main():
    n, y = map(int, input().split())

    for i in range(n + 1):
        for j in range(n + 1):
            if n - i - j >= 0 and 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
                print(i, j, n - i - j)
                exit()
    else:
        print("-1 -1 -1")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9176
//
//  main.cpp
//  AtCoder_138D
//
//  Created by Hsiu-Fen Chou on 2019/12/8.
//  Copyright © 2019 Hsiu-Fen Chou. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;
#define maxn 200005
vector<int> G[maxn];
long long timer[maxn];
long long ans[maxn];

void dfs(int now, int pre, int Time){
    Time += timer[now];
    ans[now] = Time;
    for (auto nxt: G[now]){
        if (nxt == pre) continue;
        dfs(nxt, now, Time);
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N, Q, a, b, p, x;
    cin >> N >> Q;
    for (int i=1; i<=N-1; i++){
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    while (Q--){
        cin >> p >> x;
        timer[p] += x;
    }
    dfs(1, 0, 0);
    for (int i=1; i<=N; i++){
        cout << ans[i] << ' ';
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 25600
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int a,b,c,d;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>a>>b>>c>>d;
    int x=c/b;
    if( (c%b)!=0) x++;
    int y=a/d;
    if( (a%d)!=0) y++;
    if(x<=y){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}    

Measured memory_bytes: 3612
a=[0]*9
u=[0]*9
unchimode=False
a[0],a[1],a[2]=map(int,input().split())
a[3],a[4],a[5]=map(int,input().split())
a[6],a[7],a[8]=map(int,input().split())
n = int(input())
b=[]
for i in range(n):
  hantei = int(input())
  for t in range(9):
    if a[t]==hantei:
      u[t]=1
if u[0]==1 and u[1]==1 and u[2]==1:
  unchimode=True
elif u[3]==1 and u[4]==1 and u[5]==1:
  unchimode=True
elif u[6]==1 and u[7]==1 and u[8]==1:
  unchimode=True
elif u[0]==1 and u[3]==1 and u[6]==1:
  unchimode=True
elif u[1]==1 and u[4]==1 and u[7]==1:
  unchimode=True
elif u[2]==1 and u[5]==1 and u[8]==1:
  unchimode=True
elif u[0]==1 and u[4]==1 and u[8]==1:
  unchimode=True
elif u[2]==1 and u[4]==1 and u[6]==1:
  unchimode=True
if unchimode:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def run():
    N = int(input())
    A = list(map(int, input().split()))
    total = 0
    for a in A:
        total ^= a

    for a in A:
        print(a ^ total)



if __name__ == "__main__":
    run()

Measured memory_bytes: 33164
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<math.h>


int main(){
    char S[11],T[12];
    scanf("%s %s",S,T);
    for (int i=0; S[i]!='\0'; i++) {
        if(S[i]!=T[i]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

class BIT{
    public:
    int size;
    vector<ll> tree;
    
    void set(int n){
        size = n;
        tree = vector<ll>(n+1, 0);
        return;
    }
    
    void add(int n, ll a) {
        int x = n;
        while (x <= size){
            tree[x] += a;
            x += (x & -x);
        }
        return;
    }
    
    ll getsum(int n) {
        int x = n;
        ll sum = 0;
        while (x > 0) {
            sum += tree[x];
            x -= (x & -x);
        }
        return sum;
    }
    
};

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<ll> c(N+1, 0);
    for (int i = 1; i <= N; i++) cin >> c[i];
    vector<int> pre(N+1, -1);
    vector<pair<pair<int, int>, int>> event;
    for (int i = 1; i <= N; i++) {
        if (pre[c[i]] == -1) {
            pre[c[i]] = i;
            continue;
        }else {
            event.push_back({{pre[c[i]], i}, -1});
            pre[c[i]] = i;
        }
    }
    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        event.push_back({{l, r}, i});
    }
    sort(event.begin(), event.end(), [](auto x, auto y){if (x.first.first != y.first.first) return x.first.first > y.first.first;
                                                        else return x.second < y.second;});
    vector<int> ans(Q, 0);
    BIT bit;
    bit.set(N+5);
    for (auto e : event) {
        int idx = e.second;
        if (idx == -1) {
            bit.add(e.first.second, 1);
        }else {
            ans[idx] = e.first.second - e.first.first+1;
            ans[idx] -= bit.getsum(e.first.second);
        }
    }
    for (int i = 0; i < Q; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


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

using namespace std;
const int MAX = 1e5+5;
int dp[MAX][3] , v[MAX][3];

int main()
{

    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;

    for( int i = 1; i <= n ; i++ )
        cin>>v[i][0]>>v[i][1]>>v[i][2];

    for( int i = 1; i <= n ; i++ ) {
        for( int j = 0 ; j < 3; j++ )
            dp[i][j] = v[i][j] + max( dp[i-1][(j+1)%3] , dp[i-1][(j+2)%3] );

    }
    cout<<max( dp[n][0] , max(dp[n][1] , dp[n][2]) )<<"\n";

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi h(n);
    rep(i,n) cin >> h.at(i);
    vi cost(n);
    cost.at(0) = 0;
    cost.at(1) = abs(h.at(1) - h.at(0));
    int64_t dx1,dx2;
    for(int64_t i=2; i<n; i++){
        dx1 = abs(h.at(i)-h.at(i-2)) + cost.at(i-2);
        dx2 = abs(h.at(i)-h.at(i-1)) + cost.at(i-1);
        cost.at(i) = min(dx1, dx2);
    }
    cout << cost.at(n-1) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int n=1e5;
int c[n]={0};
int main()
{
	int n;
	cin >>n;
	while(n--){
		int a;
		cin >>a;
		c[a-1]++;
		c[a+1]++;
		c[a]++;
	}
	int max=c[0];
	for(int i;i<100001;i++){
		if(max<c[i])	max=c[i];
	}
	cout << max <<endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    string S;
    cin >> S;
    if(S[0] == 'S') print("Cloudy");
    if(S[0] == 'C') print("Rainy");
    if(S[0] == 'R') print("Sunny");
    return 0;
}

Measured memory_bytes: 256
n, t_limit = map(int, input().split(" "))
way = [list(map(int,input().split(" "))) for i in range(n)]

c_min = 1001
for w in way:
    if w[1] <= t_limit:
        if c_min > w[0]:
            c_min = w[0]

if c_min == 1001:
    print("TLE")
else:
    print(c_min)


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

int main(){
    int n,total=0;
    cin>>n;
    int b[n];
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            total+=b[i]*b[j];
        }
    }
    cout<<total<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<map>
using namespace std;
map<char, pair<int, int>>m;
string s;
signed main() {
	int h, w, x, y, ans;
	while (cin >> h >> w, h) {
		m.clear(); x = 0; y = 0; ans = 0;
		for (int i = 0; i < h; i++) {
			cin >> s;
			for (int j = 0; j < w; j++)if (s[j] != '_')m[s[j]] = make_pair(i, j);
		}
		cin >> s;
		for (int i = 0; i < s.size(); i++) {
			ans += abs(x - m[s[i]].first) + abs(y - m[s[i]].second);
			x = m[s[i]].first; y = m[s[i]].second;
		}cout << ans+s.size() << endl;
	}
}


Measured memory_bytes: 3164
using System;

class Program
    {
        static void Main()
        {
            string[] line;
            while ((line = Console.ReadLine().Split(' ')).GetValue(1).ToString() != "?")
            {
                int x = int.Parse(line[0]);
                int y = int.Parse(line[2]);

                int result = 0;
                switch (line[1])
                {
                    case "+":
                        result = x + y;
                        break;
                    case "-":
                        result = x - y;
                        break;
                    case "*":
                        result = x * y;
                        break;
                    case "/":
                        result = x / y;
                        break;
                }

                Console.WriteLine(result.ToString());
            }
        }
    }

Measured memory_bytes: 5708
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++)cin>>p[i];
  for(int i=0;i<n;i++)cin>>q[i];
  
  vector<long long> a(n),ans;
  for(int i=0;i<n;i++)a[i]=i+1;
  long long cnt=0;
  do{
    cnt++;
    bool ok1=true;
    for(int i=0;i<n;i++){
      if(a[i]!=p[i])ok1=false;
    }
    bool ok2=true;
    for(int i=0;i<n;i++){
      if(a[i]!=q[i])ok2=false;
    }
    if(ok1)ans.push_back(cnt);
    if(ok2)ans.push_back(cnt);
  }while(next_permutation(a.begin(),a.end()));
  cout<<abs(ans[1]-ans[0])<<endl;
  return 0;
}
  

Measured memory_bytes: 3584
from collections import deque
N, M = map(int, input().split())

X = [[] for i in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    X[x-1].append(y-1)

S, T = map(int, input().split())
S -= 1
T -= 1
Q0 = deque([S])
Q1 = deque([])
Q2 = deque([])
D0 = [999999] * N
D1 = [999999] * N
D2 = [999999] * N

D0[S] = 0
while Q0 or Q1 or Q2:
    while Q0:
        x = Q0.popleft()
        for c in X[x]:
            if D1[c] == 999999:
                D1[c] = D0[x]+1
                Q1.append(c)
    while Q1:
        x = Q1.popleft()
        for c in X[x]:
            if D2[c] == 999999:
                D2[c] = D1[x]+1
                Q2.append(c)
    while Q2:
        x = Q2.popleft()
        for c in X[x]:
            if D0[c] == 999999:
                D0[c] = D2[x]+1
                Q0.append(c)
print(-1 if D0[T] == 999999 else D0[T]//3)


Measured memory_bytes: 30168
#include <stdio.h>

int main(void){
  long long int a,ans=0;
  scanf("%lld\n",&a);
if (a>=105) {
  ans++;
}
if (a>=135) {
  ans++;
}
if (a>=165) {
  ans++;
}
if (a>=189) {
  ans++;
}
if (a>=195) {
  ans++;
}
printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    string b;
    cin >>b;
    if(b=="A"){
        cout <<"T";
    }else{
        if(b=="C"){
            cout <<"G";
        }else{
            if(b=="G"){
                cout <<"C";
            }else{
                cout <<"A";
            }
        }
    }
}


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

int main(){
    string O, E;
    cin >> O >> E;

    int A = O.size();
    int B = E.size();
    int C = max(A, B);
    
    for(int i = 0; i < C; i++){
        if(i < A){
            cout << O.at(i);
        }
        if(i < B){
            cout << E.at(i);
        }
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
	int n;
	int a[2];
	cin>>n>>a[0]>>a[1];

	mint c=2;
	mint tot=c.pow(n);

	rep(k, 2){
		mint com=1, div=1;
		rep(i, a[k]) com*=n-i;
		rep(i, a[k]) div*= i+1;
		com /= div;

		tot-=com;
	}
	tot-=1;

	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 3644
from itertools import groupby

a = ['_','.,!? ','abc','def','ghi','jkl','mno','pqrs','tuv','wxyz']
for i in xrange(input()):
	b = [[i for i in j] for i,j in groupby(raw_input())]
	c = []
	d = ''
	for i in b:
		index = int(i[0])
		s = a[index][(len(i))%len(a[index])-1]
		if s == '_':
			d = d + ''.join(c)
			c = []
		else:
			c.append(s)
	print d

Measured memory_bytes: 4388
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
A=[]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    A.append([a,b])
A=sorted(A,key=lambda x:x[0],reverse=True)
cnt,b=0,n-1
for i in range(m):
    if A[i][1]<=b:
        cnt+=1
        b=A[i][0]
print(cnt)

Measured memory_bytes: 22052