akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int a[10], ans = 0, ans2 = INF;
	
	for(int i = 0; i < 5; i++){
		cin>>a[i];
		ans += ((a[i]+9)/10)*10;
		// cout<<ans<<endl;
	}
	for(int i = 0; i < 5; i++){
		ans2 = min(ans2, ans-((a[i]+9)/10)*10 + a[i]);
	}
	
	cout<<ans2<<endl;
	
	return 0;
}

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


class DP{
public:
	int cost, n, x;
	
	DP(){}
	DP(int xx, int nn, int cc){
		cost = cc;x=xx;n=nn;
	}
	
	bool operator< (const DP &opp) const {
		return cost>opp.cost;
	}
};
int C[20];
int x[20001];
bool visit[20001][256];
int N, M;
main(){
	int i,j;
	while(cin >> N >> M, N){
		memset(visit, 0, sizeof(visit));
		for(i=0;i<M;i++) cin >> C[i];
		for(i=0;i<N;i++) cin >> x[i];
		priority_queue<DP> dp;
		DP S;
		dp.push(DP(128, 0, 0));
		while(!dp.empty()){
			S = dp.top();
			dp.pop();

			if(S.n == N) break;
			for(i=0;i<M;i++){
				DP T=S;
				T.x += C[i];
				if(T.x > 255) T.x = 255;
				if(T.x < 0) T.x = 0;
				
				T.cost += (x[T.n]-T.x)*(x[T.n]-T.x);
				T.n ++;
				if(visit[T.n][T.x]) continue;
				visit[T.n][T.x] = true;
				dp.push(T);
			}
		}
		cout << S.cost << endl;
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    for(int n = 1; n <= N; n++){
        int cnt = 0;
        for(int x = 1; x*x <= n-5; x++){
            for(int y = x; y*y <= n-5; y++){
                for(int z = y; z*z <= n-5; z++){
                    if(x*x + y*y + z*z == n - x*y - y*z - z*x){
                        if(x == y && x == z){
                            cnt++;
                        }else if(x != y && y != z && z != x){
                            cnt += 6;
                        }else{
                            cnt += 3;
                        }
                    }
                }
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stack>
using namespace std;
int n, m;
string s;
int cnt;
vector<int> v;
int main(){
	stack<int> st;
	int ans = 0;
	while (cin >> s) {
		ans = 0;
		if (s == "+") {
			ans = st.top();
			st.pop();
			ans += st.top();
			st.pop();
			st.push(ans);
		}
		else if (s == "-") {
			ans = -st.top();
			st.pop();
			ans += st.top();
			st.pop();
			st.push(ans);
		}
		else if (s == "*") {
			ans = st.top();
			st.pop();
			ans *= st.top();
			st.pop();
			st.push(ans);
		}
		else {
			int a=0, t=1;
			for (int i = 0; i < s.size(); ++i) {
				a += (s[s.size() - 1 - i] - '0')*t;
				t *= 10;
			}
			st.push(a);
		}
	}
	std::cout << st.top() << endl;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    LL(W,H,x,y);
    cout << float(W)*float(H) / 2 << " "
    <<(x+x == W && y+y == H);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

int main()
{
	int N;
	std::vector<int> H;

	std::cin >> N;
	H.resize(N);
	for (auto& h : H)
		std::cin >> h;

	int cur = H[0] - 1;
	for (int i = 1; i < N; ++i) {
		if (cur == H[i]) {
			continue;
		} else if (cur > H[i]) {
			std::cout << "No\n";
			return 0;
		} else {
			cur = H[i] - 1;
		}
	}
	std::cout << "Yes\n";
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
#include<cstring>
using namespace std;
typedef	long long int ll;

vector<int> g[200]; //max_vは最大頂点数、隣接リスト表現
int match[200]; //マッチングのペア
bool used[200]; //DFSですでに調べたかのフラグ

//uとvを結ぶ辺を追加
void add_edge(int u, int v){
    g[u].push_back(v);
    g[v].push_back(u);
}

//増加パスをDFSで探す
bool dfs(int v){
    used[v] = 1;
    for(int i = 0; i < g[v].size(); i++){
        int u = g[v][i], w = match[u];
        if(w < 0 || !used[w] && dfs(w)){
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

// 二部グラフの最大マッチングを求める、Vは頂点数
int bipartite_mathcing(int V){
    int res = 0;
    memset(match, -1, sizeof(match));
    for(int v = 0; v < V; v++){
        if(match[v] < 0){
            memset(used, 0, sizeof(used));
            if(dfs(v)) res++;
        }
    }
    return res;
}

int main(){
    int n;
    vector< pair<int, int> > v;
    cin >> n;
    int x, y;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        v.push_back(make_pair(x,y));
    }
    for(int i = n; i < 2*n; i++){
        cin >> x >> y;
        for(int j = 0; j < n; j++){
            if(v[j].first < x && v[j].second < y){
                g[j].push_back(i);
                g[i].push_back(j);
            }
        }
    }
    int res = bipartite_mathcing(2*n);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	static int h=0;
	static int w=0;
	static int map[][];
	static int ct=0;
	public static void main(String[]args){
		Scanner s=new Scanner(System.in);
		while(true){
			w=s.nextInt();h=s.nextInt();if(h==0&&w==0){break;}map=new int[h+2][w+2];
			for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
			map[i][j]=s.nextInt();
			}}	//forfor
					for(int k=0;k<=h+1;k++){map[k][0]=map[k][w+1]=0;}
					for(int l=0;l<=w+1;l++){map[0][l]=map[h+1][l]=0;}ct=1;
						for(int ph=1;ph<=h;ph++){
							for(int pw=1;pw<=w;pw++){
								if(map[ph][pw]==1){
										ct++;
										calc(ph,pw);
								}//if
							
							}}//forfor2
					System.out.println(ct-1);
			
		}}//while and main method
	public static int calc(int column,int row){
				map[column][row]=ct;
				for(int h=-1;h<=1;h++){
				for(int w=-1;w<=1;w++){
					if(map[column+h][row+w]==1){
						calc(column+h,row+w);}//if
				}}
				return 0;}//calc
}//class

Measured memory_bytes: 45276
import java.io.*;
import java.util.*;
 
public class Main{
	String L;
	long MOD = 1000000007;
	long[] memo1, memo2;
	void solve() {
		L = next();
		memo1 = new long[L.length()];
		memo2 = new long[L.length() + 1];
		out.println(dfs(0));
	}
	
	long dfs(int idx) {
		if(memo1[idx] != 0) {
			return memo1[idx];
		}
		long ans;
		if(idx == L.length() - 1) {
			if(L.charAt(idx) == '1') {
				ans = 3;
			}else {
				ans = 1;
			}
		}else {
			if(L.charAt(idx) == '0') {
				ans = dfs(idx + 1);
			}else {
				ans = pow3(idx + 1) + 2 * dfs(idx + 1);
			}
		}
		return memo1[idx] = ans % MOD;
	}
	
	long pow3(int idx) {
		if(idx == L.length()) {
			return 1;
		}
		if(memo2[idx] != 0) {
			return memo2[idx];
		}
		return memo2[idx] = (3 * pow3(idx + 1)) % MOD;
	}
	
	
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

typedef struct edge_def {
  int from;
  int to;
  int cost;

  edge_def(int _from, int _to, int _cost) {
    from = _from;
    to   = _to;
    cost = _cost;
  }
} edge;

const int INF = INT_MAX;
const int V = 100;
int n, t;
vector<edge> es[V];
int d[V];

void bellman_ford(int s) {
  int i, j;
  for (i=0; i<n; i++) d[i] = INF;
  d[s] = 0;
  
  while (1) {
    bool update = false;
    for (i=0; i<n; i++)
      for (j=0; j<(int)es[i].size(); j++) {
        edge e = es[i][j];
        if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
          d[e.to] = d[e.from] + e.cost;
          update = true;
        }
      }
    if (!update) break;
  } 
}

int main() {
  int i, j;
  for (i=0; i<V; i++) es[i].clear();

  scanf("%d ", &n);
  for (i=0; i<n; i++) {
    int u, v, k;
    scanf("%d ", &u);
    scanf("%d ", &k);
    for (j=0; j<k; j++) {
      scanf("%d ", &v);
      es[u-1].psb(edge(u-1, v-1, 1));
    }
  }

  bellman_ford(0);

  for (i=0; i<n; i++) {
    if (d[i]==INF) d[i] = -1;
    printf("%d %d\n", i+1, d[i]);
  }

	return 0;
}

Measured memory_bytes: 1196
N, M = gets.split.map(&:to_i)
A = {}
M.times { A[gets.to_i] = true }
MOD = 1000000007

dp = Array.new(N + 1, 0)
dp[0] = 1

1.upto(N) do |i|
  next if A[i]
  dp[i] = dp[i - 1]
  dp[i] += dp[i - 2] if i > 1
  dp[i] %= MOD
end

puts dp[N]


Measured memory_bytes: 9340
a=int(input())
b=int(input())
c=int(input())
n=int(input())
ans=0
for i in range(a+1):
  for j in range(b+1):
    for h in range(c+1):
      if 500*i+100*j+50*h==n:
        ans+=1
print(ans)

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

#define int long long
#define fi first
#define se second
const int oo = 1e9 + 7;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;

int n, par[100001], sz[100001];
vector<iii> point, edg;

int dist(int a, int b, int c, int d){
	return min(abs(a - c), abs(b - d));
}

int anc(int x){
	if(par[x] == -1) return x;
	else return (par[x] = anc(par[x]));
}

bool issameset(int x, int y){ return (anc(x) == anc(y));}

void uni(int x, int y){
	x = anc(x);
	y = anc(y);
	if(sz[x] > sz[y]){
		sz[x] += sz[y];
		par[y] = x;
	}
	else{
		sz[y] += sz[x];
		par[x] = y;
	}
}

bool cmp(iii a, iii b){
	return a.se < b.se;
}

signed main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		iii pt;
		cin >> pt.fi.fi >> pt.fi.se;
		pt.second = i;
		point.push_back(pt);
	}
	point.push_back(make_pair(make_pair(-oo, -oo), 0));
	point.push_back(make_pair(make_pair(2 * oo, 2 * oo), 0));
	sort(point.begin(), point.end());
	for(int i = 2; i <= n; i++){
	    edg.push_back(make_pair(make_pair(point[i].se, point[i - 1].se), dist(point[i].fi.fi, point[i].fi.se, point[i - 1].fi.fi, point[i - 1].fi.se)));
	}
	for(int i = 1; i <= n; i++) swap(point[i].fi.fi, point[i].fi.se);
	sort(point.begin(), point.end());
	for(int i = 2; i <= n; i++){
	    edg.push_back(make_pair(make_pair(point[i].se, point[i - 1].se), dist(point[i].fi.fi, point[i].fi.se, point[i - 1].fi.fi, point[i - 1].fi.se)));
	}
	//cout << edg[3].fi.fi << " " << edg[3].fi.se << endl;
	for(int i = 1; i <= n; i++) par[i] = -1;
	sort(edg.begin(), edg.end(), cmp);
	int ans = 0;
	for(int i = 0; i < edg.size(); i++){
	    //cout << edg[i].fi.fi << " " << edg[i].fi.se << " " << edg[i].se << " ";
	    if(!issameset(edg[i].fi.fi, edg[i].fi.se)){
	        //cout << 1;
	        ans += edg[i].se;
	        uni(edg[i].fi.fi, edg[i].fi.se);
	    }
	    cout << endl;
	}
	cout << ans;
}

Measured memory_bytes: 11116
import heapq


def neg_int(a):
    return -1 * int(a)


n, m = map(int, input().split())
a = sorted(list(map(neg_int, input().split())))
heapq.heapify(a)

for i in range(m):
    value = -1 * ((-1 * heapq.heappop(a)) // 2)
    heapq.heappush(a, value)

print(sum(a) * -1)

Measured memory_bytes: 14252
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M;
    cin >> M;
    cout << 48 - M << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef uint64_t u64;
typedef uint32_t u32;

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  i32 sum = 0;
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
    sum += a[i];
  }
  const u32 b = sizeof (u64) * 8;
  const i32 len = (sum + b - 1) / b;
  u64 *dp = (u64 *) calloc (len + 1, sizeof (u64));
  dp[0] = 1;
  for (i32 i = 0, local = 0; i < n; local += a[i], ++i) {
    const u32 v = a[i];
    u32 p = v / b;
    u32 q = v % b;
    if (q == 0) {
      for (i32 j = local / b; j >= 0; --j) {
        dp[j + p] |= dp[j];
      }
    } else {
      for (i32 j = local / b; j >= 0; --j) {
        u64 y = dp[j];
        dp[j + p] |= y << q;
        dp[j + p + 1] |= y >> (b - q);
      }
    }
  }
  i32 m = (sum + 1)/ 2;
  while (((dp[m / b] >> (m % b)) & 1) == 0) m++;
  printf ("%" PRIi32 "\n", m);
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    cout << a.size() << endl;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
	int n, m;
	cin >> n >> m;
	cout << (1 << m) * (m * 1900 + (n - m) * 100) << "\n";
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) (n); i++)
long long int INF=1001001000;

int main() {
	int a,b;
	cin >> a >> b;
	if(a<=5) cout << 0 << endl;
	else if(12<a) cout << b << endl;
	else cout << b/2 << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        List<Point> personList = new ArrayList<>();
        List<Point> checkPointList = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            Point p = new Point(scanner.nextInt(), scanner.nextInt());
            personList.add(p);
        }
        for (int i = 0; i < M; i++) {
            Point p = new Point(scanner.nextInt(), scanner.nextInt());
            checkPointList.add(p);
        }

        for (Point person: personList) {
            long min = 1000000000;
            long minCheckPoint = -1;
            for (int i = 0; i < M; i++) {
                Point checkPoint = checkPointList.get(i);
                long d = Math.abs(person.x - checkPoint.x) + Math.abs(person.y - checkPoint.y);
                if (d < min) {
                    min = d;
                    minCheckPoint = i + 1;
                }
            }
            System.out.println(minCheckPoint);
        }
    }

    class Point {
        long x;
        long y;
        public Point(long x, long y) {
            this.x = x;
            this.y = y;
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


Measured memory_bytes: 22612
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String A;
        TreeMap<String,Integer> B=new TreeMap<>();
        int max=0;
        int count;
        for (int i = 0; i < N; i++) {
            A = sc.next();
            if (B.containsKey(A)) {
                count=B.get(A)+1;
                B.put(A, count);
            }else{
                B.put(A, 1);
            }
            max=Math.max(B.get(A), max);
        }

        //System.out.println(B.toString());

        for (String str : B.keySet()) {
            if (B.get(str)==max) {
                System.out.println(str);
            }
        }
    }
}

Measured memory_bytes: 76740
def main():
    h, w = [int(x) for x in input().split()]
    matrix = [list(input()) for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if matrix[i][j] == '.':
                continue
            # Above
            if i > 0:
                if matrix[i - 1][j] == '#':
                    continue
            # Left
            if j > 0:
                if matrix[i][j - 1] == '#':
                    continue
            # Right
            if j < w - 1:
                if matrix[i][j + 1] == '#':
                    continue
            # Below:
            if i < h - 1:
                if matrix[i + 1][j] == '#':
                    continue

            # The cell is black and no adjacent black cell.
            return 'No'

    return 'Yes'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 38896
from itertools import accumulate
import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_acc = [0] + list(accumulate(a))  # aを0冊読む=1冊も読まない場合があるので、[0]を先頭に追加します
b_acc = list((accumulate(b)))  # bisect_rightでは、x以下の要素がいくつあるか？を求めるので、こちらに0は入れません

ans = 0
for an in range(n + 1):
    rem = k - a_acc[an]
    if rem < 0:
        # aをこれ以上読めません
        break

    bn = bisect.bisect_right(b_acc, rem)
    ans = max(ans, an + bn)

print(ans)

Measured memory_bytes: 48888
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL c_count = 0;

void f(int x, int parent, vector<VL> &link, VL &c, VL &ans){
    REP(i, link[x].size()){
        if(link[x][i] != parent)f(link[x][i], x, link, c, ans);
    }
    ans[x] = c[c_count];
    c_count++;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<VL> link(n);
    VL a(n);
    VL b(n);
    REP(i,n-1){
        cin>>a[i]>>b[i];
        link[a[i] - 1].PB(b[i] - 1);
        link[b[i] - 1].PB(a[i] - 1);
    }

    VL c(n);
    REP(i, n)cin>>c[i];
    SORT(c);

    VL ans(n, 0);
    c_count = 0;
    f(0, -1, link, c, ans);
    LL sum = 0;
    REP(i,n-1){
        sum += min(ans[a[i] - 1], ans[b[i] - 1]);
    }
    PUTS(sum);
    REP(i,n){
        cout<< ans[i] << " ";
    }

    //vector<tuple<LL,LL,LL>> node(n);
    //REP(i,n){
    //    node[i] = make_tuple(link[i].size(), i, 0);
    //}
    //SORT(node);
    //REP(i, n){
    //    get<2>(node[i]) = c[i];
    //}
    //sort(ALL(node), [](const auto a, const auto b){return get<1>(a) < get<1>(b);});
    //LL sum = 0;
    //REP(i,n-1){
    //    sum += min(get<2>(node[a[i] - 1]), get<2>(node[b[i] - 1]));
    //}
    //PUTS(sum);
    //REP(i,n){
    //    cout<< get<2>(node[i]) << " ";
    //}
}

Measured memory_bytes: 1920
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

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

		while (sc.hasNext()) {
			double a = sc.nextDouble(); // a
			double b = sc.nextDouble(); // b
			double c = sc.nextDouble(); // c
			double d = sc.nextDouble(); // d
			double e = sc.nextDouble(); // e
			double f = sc.nextDouble(); // f

			double x = (c * e - b * f) / (a * e - b * d);
			double y = (f * a - c * d) / (a * e - d * b);

			BigDecimal xx = new BigDecimal(x);
			BigDecimal yy = new BigDecimal(y);
			BigDecimal solutionX = xx.setScale(3, BigDecimal.ROUND_HALF_UP);
			BigDecimal solutionY = yy.setScale(3, BigDecimal.ROUND_HALF_UP);

			System.out.println(solutionX + " " + solutionY);
		}
	}
}

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

using namespace std;

typedef long long ll;
#define INF (1<<29)
#define INFF 0x7fffffff
#define LINF (1ll<<60)
#define LINFF 0x7fffffffffffffff
#define PI 3.14159265359
#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define YESNO(ans) cout << (ans?"YES":"NO") << endl;
#define pqueue priority_queue
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'

bool prime(int x){
    if (x <= 2) return true;
    for(int i = 2;i*i <= x;i++){
        if (x%i == 0) return false;
    }
    return true;
}


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

    int x;cin>>x;
    while(!prime(x)) x++;
    cout << x << endl;

    return 0;
}


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

int main() 
{ 
int n,k;
cin>>n>>k;
int ha[n+1]={0};
while(k--){
    int h;
    cin>>h;
    while(h--){
        int p;
        cin>>p;
        ha[p]++;
    }
}
int c=0;
for(int u=1;u<=n;u++){
    if(ha[u]==0)
    c++;
}
cout<<c;
} 


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

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

void solve(int n){
    int cnt=0,cnt2=0;
    rep(i,n){
        int x;
        cin>>x;
        if(x>=2)cnt2++;
        if(x>=1)cnt++;
    }
    if(cnt2==0){
        cout<<"NA"<<endl;
    }
    else cout<<cnt+1<<endl;
}

int main(){
    int n;
    while(cin>>n,n!=0)solve(n);
}


Measured memory_bytes: 3100
//前置き
#pragma region

#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

#pragma endregion

//関数定義
#pragma region 
//偶数 ->　true :: 奇数　-> false
bool EVEN(ll a){
    return a%2-1;
}

//最大公約数
ll gcd(ll a, ll b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}  

//最小公倍数
ll lcm(ll a, ll b) {  
    return a*b/gcd(a,b);  
} 

#pragma endregion


int main(){
    while(1){
        int w, h, cnt =1;
        cin >> w >> h;
        if(w == 0 && h == 0) return 0;

        bool vis[22][22];
        char gragh[22][22];

        REP(i,22){
            REP(j,22){
                vis[i][j] = false;
                gragh[i][j] = '#';
            }
        }

        


        int a,b;
        for(int i=1;i<h+1;i++){
            for(int j=1;j<w+1;j++){
                cin >> gragh[i][j];

                if(gragh[i][j] == '@'){
                    a = i;b = j;
                }
            }   
        }

        
        stack<int> st;
        st.push(a); st.push(b);
        int dx[4] = {0,1,-1,0};
        int dy[4] = {1,0,0,-1};
 

        while (!st.empty()){
            int x,y;
            y = st.top(); st.pop();
            x = st.top(); st.pop();

            for(int i = 0;i<4;i++){
                int ix = x + dx[i];
                int iy = y + dy[i];
            
                if(gragh[ix][iy] == '.' && vis[ix][iy] == false){
                    st.push(ix); st.push(iy);
                    vis[ix][iy] = true;
                    cnt ++;
                }
            }
        }
        cout << cnt <<endl;
    }
}



Measured memory_bytes: 3088
//##MohK
//13/2/2020.... 8,21
#include <bits/stdc++.h>
using namespace std ;
using ll = long long ;
using ld = long double;
int main(){
    ll counter=0;
    string a;
    cin>>a;
    for(ll i=0;i<a.size()/2;i++){
       if(a[i]!=a[a.size()-1-i])counter++;
    }
     cout<<counter<<endl;


 return 0 ;
}




Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<set>
#include<fstream>
#include<map>
#include<vector>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
int Prim[60000],rwa[60000];
bool isp[60000];
int sieve(int n) {
	int p = 0;
	rep(i, n + 1)isp[i] = true;
	isp[0] = isp[1] = false;
	for (int i=2; i <= n; i++) {
		if (isp[i]) {
			Prim[p++] = i;
			for (int j = 2 * i; j <= n; j += i)isp[j] = false;
		}
	}
	return p;
}

bool Pr(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (!(n%i))return false;
	}
	return n >1;
}
signed main() {
	int n; cin >> n;
	int S = sieve(55555);
	vector<int>V;
	rep(i, S) {
		if (Prim[i] % 5 == 2)V.push_back(Prim[i]);
	}
	rep(i, n) {
		if (i)cout << ' '; cout << V[i] ;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}

int main()
{
    std::string word;
    std::string w = "Yes";
    int64_t a,b,c,d,e,f;
    std::cin>> word;

    if( word[2] == word[3]
        && word[4] == word[5] )
    {
        w = "Yes";
    }
    else
    {
        w = "No";
    }

    std::cout<< w;
}


Measured memory_bytes: 256
S=list(input())

t=True
for i in range(int(len(S)/2)):
    if S[i]!=S[(i+1)*-1]:

        t=False
        break

s_max =len(S)-1
S_befor = S[0:int(s_max/2)]
for i in range(int(len(S_befor)/2)):
    if S_befor[i]!=S_befor[(i+1)*-1]:

        t=False
        break

S_after = S[int((len(S)+3)/2):-1]
for i in range(int(len(S_after)/2)):
    if S_after[i]!=S_after[(i+1)*-1]:
        t=False
        break

if t==True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d,e, H, W,L;
long long A[200005] = {};
long long B[200005] = {};
long long C[200005] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl;
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


bool fs[2005][2005] = {};

int main() {


	cin >> S;

	A[0] = 1;
	B[0] = 2;
	
	for (int i = 1; i < S.size(); i++) {
		if (S[i] == '1') {
			A[i] = A[i - 1]*3+B[i-1];
			B[i] = B[i - 1]*2;
		}
		else {
			A[i] = A[i - 1]*3;
			B[i] = B[i - 1];
		}
		A[i] %= modd;
		B[i] %= modd;
	}
	
	c = A[S.size() - 1] + B[S.size() - 1];
	c %= modd;
	cout << c << endl;
	
	return 0;

}


Measured memory_bytes: 5248
from math import ceil
N,K = map(int, input().split())
A = list(map(int, input().split()))

def is_ok(arg):
  # 条件を満たすかどうか？問題ごとに定義
  # arg以下になるように各々の木をきる。回数を足し合わせて、K以下かどうか判定する
  cnt = 0
  for a in A:
    cnt += ceil(a / arg) - 1
  return cnt <= K

def meguru_bisect(ng, ok):
  '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
  '''
  while (abs(ok - ng) > 1):
    mid = (ok + ng) // 2
    if is_ok(mid):
      ok = mid
    else:
      ng = mid
  return ok

ng = 0
ok = 10**9 + 1

ans = meguru_bisect(ng,ok)
print(ceil(ans))


Measured memory_bytes: 31092
#include<stdio.h>
#include<stdlib.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMin）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,i,a,b=0,M=1e9+7;
  long long s=1,c=1,d[100010]={1,1};
  for(i=1;i<=100000;i++)d[i]=(d[i-1]*i)%M;
  scanf("%d",&n);
  for(i=0;i<n*2;i++){
    scanf("%d",&a);
    hin(a);
  }
  for(i=0;i<n*2;i++){
    a=hout();
    //printf("%d %d %d\n",a,N[a],b);
    if(a<=n){
      if(b<0)s=(s*abs(b))%M;
      b++;
    }
    else{
      if(b>0)s=(s*abs(b))%M;
      b--;
    }
    //(a=hout())<=n?(b++):(b--);//printf("%d\n",b);
    // if(b&&a>n)s=(s*abs(b))%M;
  }
  printf("%lld\n",s);
  return 0;
}


Measured memory_bytes: 4992
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var D = new Dictionary<int,int>();
		foreach(var n in A){
			if(!D.ContainsKey(n)) D.Add(n, 0);
			D[n]++;
		}
		
		var L = new List<Tuple<int,int>>();
		foreach(var k in D.Keys){
			L.Add(new Tuple<int,int>(k, D[k]));
		}
		L.Sort((p,q) => p.Item2.CompareTo(q.Item2));
		L.Reverse();
		int tot = 0;
		for(int i=0;i<Math.Min(K,L.Count);i++){
			tot += L[i].Item2;
		}
		Console.WriteLine(N-tot);
		
		
	}
	int N,K;
	int[] A;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 37160
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int main() {
  string t,s="";
  bool ck=false;
  while(getline(cin,t)) {
    if(t==".") break;
    rep(i,t.size()) {
      if(t[i]=='(' || t[i]==')' || t[i]=='[' || t[i]==']') s+=t[i];
      if(t[i]=='.') ck=true;
    }
    if(ck) {
      stack<char> a;
      rep(i,s.size()) {
	if(a.size()) {
	  if((a.top()=='(' && s[i]==')') || (a.top()=='[' && s[i]==']')) a.pop();
	  else a.push(s[i]);
	} else a.push(s[i]);
      }
      if(!a.size()) pr("yes");
      else pr("no");
      ck=false;
      s="";
    }
  }
  return 0;
}


Measured memory_bytes: 1184
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
border = sum(a) / (4 * m)
cnt = 0
for i in a:
    if cnt >= m:
        break
    if i >= border:
        cnt += 1
if cnt >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#define MOD 1000000007
using namespace std;

int a,b,c;

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a;
	cout<<(a*(a+1))/2;
		return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
	int res;
	int h, m, s;
	while (scanf("%d%d%d", &h, &m, &s)) {
		res = 120;
		if (h==-1&&m==-1&&s==-1) break;
		m += h * 60;
		res -= m;
		if (s != 0) {
			res--;
			s = 60 - s;
		}
		h = (int)(res / 60);
		m = res - h * 60;
//		printf("%d\n",res);
		printf("%02d:%02d:%02d\n", h, m, s);
		res *= 3;
		s *= 3;
		res += s / 60;
		s -= s / 60 * 60;
		h = (int)(res / 60);
		m = res - h * 60;
		printf("%02d:%02d:%02d\n", h, m, s);
	}
}

Measured memory_bytes: 0
import sys

def inout(n):
    print("?", n)
    sys.stdout.flush()
    S = input()
    return S == "Y"

def main():
    Length = -1
    for l in range(11):
        if not inout(10**l):
            Length = l
            break
    if Length == -1:
        for l in range(11):
            if inout(2*10**l):
                print("!", 10**l)
                return
    tmp = ""
    for _ in range(Length):
        l = 0
        r = 10
        while r - l > 1:
            m = (r+l)//2
            if inout(int(tmp + str(m) + "0"*(Length - len(tmp)))):
                r = m
            else:
                l = m
        if len(tmp) == Length-1:
            if l == 0 and inout(int(tmp + "0"*2)):
                tmp += str(l)
            else:
                tmp += str(l+1)
        elif len(tmp) == 0 and l == 0:
            tmp += str(1)
        else:
            tmp += str(l)
    print("!", tmp)
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 3404
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;


int main(){
  string s;
  cin >> s;
  int i;
  int bad = 0;
  for(i=0;i<s.length();i++){
    if((i%2) == 0){
      if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')){
        bad = 1;
      }
    }
    else{
      if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')){
        bad = 1;
      }
    }
  }

  if(bad){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }

}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;
using namespace std;

ll N,M;

// 双方向
set<ll> orig_edges[100010];
set<ll> tree_edges[100010]; // 全域木を構成する辺

// 片方向
set<ll> ans[100010]; // ans[src] = {次の頂点dst}

bool done[100010];
void dfs(ll cur, ll par) {
  if (par!=-1){
    tree_edges[cur].insert(par);
    tree_edges[par].insert(cur);
  }
  done[cur] = true;
  for (auto c: orig_edges[cur]) {
    if (!done[c]){
      dfs(c, cur);
    }
  }
}

bool done2[100010];
void dfs2(ll cur, ll par) {
  done2[cur] = true;
  for (auto c: tree_edges[cur]) {
    if (!done2[c]){
      dfs2(c, cur);
    }
  }
  ll outdegree = ans[cur].size() % 2;
  if (par != -1) {
    if (outdegree == 0) {
      ans[par].insert(cur);
    } else {
      ans[cur].insert(par);
    }
  }
}

signed main() {
  cin>>N>>M;
  rep(i,0,M){
    ll a,b;
    cin>>a>>b;
    orig_edges[a].insert(b);
    orig_edges[b].insert(a);
  }
  if (M%2 != 0) {
    cout<<-1<<endl;
    return 0;
  }
  dfs(1, -1);
  // 全域木以外の辺は適当に向きを決める
  for (int src=1; src<=N; src++) {
    for (auto dst: orig_edges[src]) {
      if (tree_edges[src].find(dst) != tree_edges[src].end())
        continue;
      if (ans[src].find(dst) == ans[src].end() && ans[dst].find(src) == ans[dst].end()) {
        ans[src].insert(dst);
      }
    }
  }
  dfs2(1, -1);
  // 答え
  for (int src=1; src<=N; src++) {
    for (auto dst: ans[src]) {
      cout<<src<<" "<<dst<<endl;
    }
  }
  return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    int max_sug = -1;
    int max_sum = -1;

    for(int i=0; i<=30; i++){
        for(int j=0; j<=30; j++){
            for(int k=0; k<=100; k++){
                for(int l=0; l<=100; l++){
                    int sug = c*k + d*l;
                    int sum = 100*a*i + 100*b*j + sug;
                    if(sum == 0) continue;
                    if(sum > f) continue;
                    if(sug > (a*i + b*j)*e) continue;
                    if(max_sug == -1 || max_sug * sum < sug*max_sum){
                        //printf("%d %d %d %d\n", i, j, k, l);
                        max_sug = sug;
                        max_sum = sum;
                    }
                }
            }
        }
    }

    printf("%d %d\n", max_sum, max_sug);   

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        Map<String,Integer> m = new HashMap<>();
        m.put("AC",0);//AC, WA, TLE, RE
        m.put("WA",0);//AC, WA, TLE, RE
        m.put("TLE",0);//AC, WA, TLE, RE
        m.put("RE",0);//AC, WA, TLE, RE

        for (int i = 0; i < N; i++) {
            String S = sc.next();
            m.put(S,m.get(S)+1);
        }
        long ans =0;
        System.out.println("AC x "+m.get("AC"));
        System.out.println("WA x "+m.get("WA"));
        System.out.println("TLE x "+m.get("TLE"));
        System.out.println("RE x "+m.get("RE"));
    }}

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


int main() {
    int n;
    const int SIZE = 2 * 100000;
    int P[SIZE];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> P[i];
    int c = 1;
    int min = P[0];
    for (int i = 1; i < n ; i ++) {
        if (P[i] < min) {
            min = P[i];
            c++;
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int double
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
using namespace std;

//author::@whohet-->Het Patel
int min(int x, int y)
{
	return (x < y) ? x : y;

}

int calcAngle(int h, int m)
{
	// validate the input


	if (h == 12) h = 0;
	if (m == 60) m = 0;

	// Calculate the angles moved
	// by hour and minute hands
	// with reference to 12:00
	int hour_angle = 0.5 * (h * 60 + m);
	int minute_angle = 6 * m;

	// Find the difference between two angles
	int angle = abs(hour_angle - minute_angle);

	// Return the smaller angle of two possible angles
	angle = min(360 - angle, angle);

	return angle;
}

signed main()
{
	fasterthanlight;
	std::cout << std::fixed;
	std::cout << std::setprecision(18);
	int a, b;
	cin >> a >> b;
	int h, m;
	cin >> h >> m;
	if (m == 0)m = 60;
	int ang = calcAngle(h, m);
	int pi = 3.141592653589793238;
	ang = (ang * pi) / 180;
	//cout << pi << endl;
	//cout << ang << " ";
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//cout << cos(ang) << " ";
	cout << sqrt((a * a) + (b * b) - (a * b * 2 * cos(ang)));


	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}



Measured memory_bytes: 4216