akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, m;
    cin >> n >> m;
    int s[m], c[m];
    rep(i,m)cin >> s[i] >> c[i];

    int ans = -1;

    if(n == 1){
        rep(i,10){
            int flag = 1;
            rep(j,m){
                if(c[j] != i)flag = 0;
            }
            if(flag){
                ans = i;
                break;
            }
            
        }
    }else if(n == 2){
        srep(i,10,100){
            int flag = 1;
            rep(j,m){
                if(s[j] == 2){
                    if(i % 10 != c[j])flag = 0;                    
                }else{
                    if(i / 10 != c[j])flag = 0;
                }
            }
            if(flag){
                ans = i;
                break;
            }
        }
    }else if(n == 3){
        srep(i,100,1000){
            int flag = 1;
            rep(j,m){
                if(s[j] == 3){
                    if(i % 10 != c[j])flag = 0;
                }else if(s[j] == 2){
                    if(i / 10 % 10 != c[j])flag = 0;
                }else{
                    if(i / 100 != c[j])flag = 0;
                }
            }
            if(flag){
                ans = i;
                break;
            }
        }
    }

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,k,q,i;
    int a;
	int player[100001]={0};

	scanf("%d%d%d",&n,&k,&q);
    
	for(i=1;i<=n;i++)
		player[i]=k-q;
	for(i=0;i<q;i++)
	{	scanf("%d",&a);
	    player[a]+=1;
	}
	for(i=1;i<=n;i++)
	{	
		if(player[i]<=0)
	        printf("No\n");
		else
			printf("Yes\n");
	}
return 0;
}

Measured memory_bytes: 896
def A():
    S = list(input())
    W = [0 for i in range(len(S))]
    B = [0 for i in range(len(S))]
    ans = 0
    if S[0] == "B":
               B[0] = 1
    else:
        W[0] = 1

    for i in range(1, len(S)):
        B[i] += B[i - 1]
        if S[i] == "B":
            B[i] += 1
        else:
            ans += B[i]
    print(ans)
A()

Measured memory_bytes: 14372
import java.util.Scanner;

public class Main {

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

    private Scanner scan = new Scanner(System.in);
    private StringBuilder str;

    public Main() {
	str = new StringBuilder(scan.next());

	scan.close();
    }

    public final void answer() {
	str.setCharAt(3, '8');
	System.out.println(str.toString());
    }
}


Measured memory_bytes: 23636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  LL n, a, b;
  cin >> n >> a >> b;
  LL t = a + b;
  LL ans = 0;
  ans += n / t * a;
  ans += min(n % t, a);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define iFOR(idx, from, upto) for (int  idx = from; idx < upto; ++idx)
#define lFOR(idx, from, upto) for (long idx = from; idx < upto; ++idx)

#define ll long long

using namespace std;

int main() {
    int n, x, y;
    cin >> n >> x >> y;

    vector<int> distances(n-1);

    int distance;

    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j < n + 1; j++) {
            distance = min(j - i, abs(x - i) + abs(y - j) + 1);
            distances[distance - 1]++;
        }
    }

    for (int i = 0; i < n-1; i++) {
        cout << distances[i] << endl;
    }

    return 0;
}


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

using namespace std;

void solve()
{
   int s,w;
   cin>>s>>w;
   
   if(w>=s)
    cout<<"unsafe";
   else
    cout<<"safe";

}

int main()
{

   ios::sync_with_stdio(0);
   cin.tie(NULL);

   solve();

   return 0;
}


Measured memory_bytes: 3628
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


N,K= nm()
s = N % K
if s > K//2:
    s = K -s 
print(s)


Measured memory_bytes: 3060
import java.util.*;
class Main{
	static Scanner sc;
	static int up[];
	static int down[];
	static int cycle,freq,comp0,comp1;
	public static void main(String[]args){
		sc=new Scanner(System.in);
		freq=sc.nextInt();
		up=new int[freq];
		down=new int[freq];
		for(int i=0;i<freq;i++){
			up[i]=0;
			down[i]=0;
			cycle=sc.nextInt();
			comp0=sc.nextInt();
			for(int j=0;j<cycle-1;j++){
				comp1=sc.nextInt();
				if(comp1-comp0>0 && comp1-comp0>up[i]){
					up[i]=comp1-comp0;
				}else if(comp1-comp0<0 && comp0-comp1>down[i]){
					down[i]=comp0-comp1;
				}
				comp0=comp1;
			}	
		}
		for(int i=0;i<freq;i++){
			System.out.println(up[i]+" "+down[i]);
		}
	}
}

Measured memory_bytes: 26804
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
    ll X,N=0,ans=100;
    cin>>X;
     for(ll i=1;ans<X;i++){
         ans=ans*1.01;
         N=i;
     }

    

    p(N);
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e8
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n;
  while (cin >> n && n) {
    vector<vector<int> > stage(n, vector<int>(n+1, 0));
    rep(i,n)rep(j,n+1) cin >> stage[i][j];

    vector<int> dp(1 << n, INF);
    dp[0] = 0;
    // 1 ~ n
    for (int bit = 0; bit < (1 << n); ++bit) {
      rep(i,n) {
        if ( (bit & (1 << i)) != 0) continue;
        int cost = stage[i][0];
        rep(j,n) {
          if ( (bit & (1 << j)) == 0) continue;
          cost = min(stage[i][j+1], cost);
        }
        int now = (bit | (1 << i));
        dp[now] = min(dp[now], dp[bit] + cost);
      }
    }
    cout << dp[(1 << n) - 1] << endl;
  }
}



Measured memory_bytes: 3428
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  lli n, f=0;
  cin >> n;
  while(n){
    if(n%10==7){
      f=1;
      break;}
    n/=10;
  }
  if(f)	cout << "Yes" << endl;
  else cout << "No" << endl;  
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

ll a,b,c;

void solve(){
    cin >> a >> b >> c;
    if(c-a-b<=0){
        cout << "No" << endl;
    }
    else{
        if(4*a*b<(c-a-b)*(c-a-b)){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl; 
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
 
int  a[102][7];
char f[102];
 
int identical(int *a, int *b)
{
    int i, j;
    memset(f, 0, sizeof(f));
    for (i = 1; i <= 6; i++) f[a[i]]++;
    for (i = 1; i <= 6; i++) f[b[i]]--;
    for (i = 1; i <= 6; i++) if (f[b[i]]) return 0;
 
    for (j = 0; j < 24; j++) {
        if (b[1] == a[rot[j][1]]) {
            for (i = 2; ; i++) {
                if (i > 6) return 1;
                if (b[i] != a[rot[j][i]]) break;
            }
        }
    }
    return 0;
}
 
int main()
{
    int n, i, j, f;
 
    n = in();
    for (i = 0; i < n; i++) {
        for (j = 1; j <= 6; j++) a[i][j] = in();
    }
    f = 1;
    for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
        if (identical(a[i], a[j])) { f = 0; goto done; }
    }
done:
    puts(f? "Yes": "No");
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define int long long int
using namespace std;

int32_t main() {
    
   int n;
   cin >> n;
   
   if(n<2)
   cout << 1;
   else if(n<4)
   cout << 2;
   else if(n<8)
   cout << 4;
   else if(n<16)
   cout << 8;
   else if(n<32)
   cout << 16;
   else if(n<64)
   cout << 32;
   else
   cout << 64;
   
    
    return 0;
}

Measured memory_bytes: 256
import sys


class Node():

	def __init__(self,id,left,right):
		
		self.id = id
		self.left = left
		self.right = right
		self.parent = -1
		self.sibling = -1
		self.degree = 0
		self.depth = 0
		self.height = 0

def define_depth(Nodes,node):

	if node.left == -1 and node.right == -1: #leaf
		return

	if node.left != -1:
		Nodes[node.left].depth = node.depth + 1
		define_depth(Nodes,Nodes[node.left])
	if node.right != -1:
		Nodes[node.right].depth = node.depth + 1
		define_depth(Nodes,Nodes[node.right])

def define_height(Nodes,node):

	h1 = 0
	h2 = 0

	if node.left != -1:
		h1 += define_height(Nodes,Nodes[node.left]) + 1
	if node.right != -1:
		h2 += define_height(Nodes,Nodes[node.right]) + 1

	return max(h1,h2)

def find_root(Nodes,node):

	if node.parent == -1:
		return node.id

	return find_root(Nodes,Nodes[node.parent])

def print_nodes(Nodes,node_id,type,output):

	#TYPE
	#0 : Preorder
	#1 : Inorder
	#2 : Postorder

	if node_id == -1:
		return

	if type == 0:
		output.append(node_id)

	print_nodes(Nodes,Nodes[node_id].left,type,output)
	if type == 1:
		output.append(node_id)
	print_nodes(Nodes,Nodes[node_id].right,type,output)
	if type == 2:
		output.append(node_id)

def test():

	n = int(sys.stdin.readline())
	Nodes = [Node(0,0,0)] * n
	root = 0

	# Reading inputs
	for i in range(n):

		inputs = list(map(int,sys.stdin.readline().split()))
		id = inputs[0]
		left = inputs[1]
		right = inputs[2]

		tmp_node = Node(id,left,right)
		Nodes[id] = tmp_node

	# Defining parent and sibling and root
	for node in Nodes:

		child_count = 0

		# Parent
		if node.right != -1:
			Nodes[node.right].parent = node.id
			child_count += 1
		if node.left != -1:
			Nodes[node.left].parent = node.id
			child_count += 1

		# Degree
		node.degree = child_count

		#Sibling
		if node.right != -1 and node.left != -1:
			Nodes[node.right].sibling = node.left
			Nodes[node.left].sibling = node.right

	# Finding root
	root = find_root(Nodes,Nodes[0])

	# Defining depth
	define_depth(Nodes,Nodes[root])

	# Defining height
	for node in Nodes:
		node.height = define_height(Nodes,node)

	output = []

	# Printing Nodes
	print_nodes(Nodes,Nodes[root].id,0,output)
	print("Preorder")
	for i in range(n):
		print(f" {output[i]}",end='')
	print()
	
	output.clear()
	print_nodes(Nodes,Nodes[root].id,1,output)
	print("Inorder")
	for i in range(n):
		print(f" {output[i]}",end='')
	print()

	output.clear()
	print_nodes(Nodes,Nodes[root].id,2,output)
	print("Postorder")
	for i in range(n):
		print(f" {output[i]}",end='')
	print()

if __name__ == "__main__":
	test()




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

const int N = (int)2e3;
int dat[N+5];

int main() {
    int n; scanf("%d", &n);
    for (int i=1; i<=n; i++) scanf("%d", dat+i);

    sort(dat+1, dat+1+n);

    long long res = 0;
    for (int i=1; i<=n; i++) for (int j=i+1; j<=n; j++) {
        int key = dat[i] + dat[j];
        int idx = lower_bound(dat+1, dat+1+n, key) - dat;
        res += (long long)max(idx-j - 1, 0);
    }

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


class BIT{
  //0オリジンBIT
public:
  typedef long long ll;
  ll n;
  vector<ll> bit;
  BIT():n(-1){};
  BIT(ll n_){
    n=1;
    while(n < n_+2) n *= 2;
    bit.resize(n+1, 0);
  }
  

  //[0, i]までの総和を得る
  ll sum(ll i){
    assert( i >= 0 && i <= n );
    i++;
    
    ll s=0;
    while(i>0){
      s = (s + bit[i]);
      i -= i & -i;
    }
    return s;
  }

  //i番目の要素にx加算(0 オリジン)
  void add(ll i,ll x){
    assert( i >= 0 && i <= n );
    i+=2;
    
    while(i <= n){
      bit[i] = (bit[i] + x);
      i += i & -i;
    }
  }
  
  ll sum(int l,int r){ //[l, r)
    assert(l <= r);
    assert( 0 <= l && l <= n);
    assert( 0 <= r && r <= n);
    return sum(r) - sum(l);
  }
};


const int N = 2001;
int n;
vector<P> W,B;
int used[N][N],mem[N][N];

int dfs(int i,int j, BIT &A){
  if(i == n && j == n) return 0;
  if(used[i][j]++) return mem[i][j];
  int a = INF, b = INF;
  
    if(i != n) {
      int idx = W[i].second;
      int cost = A.sum(0, idx);
      A.add(idx, -1);
      a = cost + dfs(i+1,j, A);
      A.add(idx, 1);
    }
    
    if(j != n){
      int idx = B[j].second;
      int cost = A.sum(0, idx);
      A.add(idx, -1);
      b = cost + dfs(i, j+1, A);
      A.add(idx, 1);
    }
    int res = min(a, b);
    return mem[i][j] = res;
}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  cin>>n;
  

  for(int i=0;i<2 * n;i++){
    char ch;
    int val;
    int idx = i;
    cin>>ch>>val;
    if(ch == 'W') W.push_back(P(val,idx));
    else B.push_back(P(val,idx));
  }
  
  sort(W.begin(),W.end());
  sort(B.begin(),B.end());

  BIT A(2 * n+10);
  for(int i=0;i<2*n;i++) A.add(i, 1);
  
  int ans = dfs(0, 0, A);
  cout<<ans<<endl;
    
  return 0;
}


Measured memory_bytes: 63232
def c_takahashi_information(C):
    b = [C[0][i] - 0 for i in range(3)]  # a_1=0の仮定の元でbを決定
    a = [C[i][0] - b[0] for i in range(3)]
    for i in range(3):
        for j in range(3):
            if a[i] + b[j] != C[i][j]:
                return 'No'
    return 'Yes'

C = [[int(i) for i in input().split()] for j in range(3)]
print(c_takahashi_information(C))

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=200010;
int n,p;
bool onCycle[N];
int in[N];
vector<int> g[N];

int mex(vector<int>& vec) {
    sort(vec.begin(),vec.end());
    vec.resize(unique(vec.begin(),vec.end())-vec.begin());
    vec.pb(INF);
    for (int i=0;i<vec.size();i++) {
        if (vec[i]!=i) return i;
    }
    return -1;
}

int dfs(int u,vector<int>& a) {
    if (a[u]!=-1) return a[u];
    vector<int> tmp;
    for (int v:g[u]) {
        tmp.pb(dfs(v,a));
    }
    a[u]=mex(tmp);
    return a[u];
}

void foo(vector<int>& vec) {
    for (int i:vec) printf("%d ",i);
    printf("\n");
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {
        scanf("%d",&p);
        g[p].pb(i);
        in[i]=p;
    }

    int root=1;
    for (int i=1;i<=n;i++) root=in[root];
    while (!onCycle[root]) {
        onCycle[root]=true;
        root=in[root];
    }

    vector<int> value(n+1,-1);
    for (int i=1;i<=n;i++) {
        if (!onCycle[i]) dfs(i,value);
    }

    int x;
    vector<int> vec;    // sg values for adjacent vertex of root
    for (int v:g[root]) {
        if (onCycle[v]) {
            x=v;
        } else {
            vec.pb(value[v]);
        }
    }

    vector<int> valueRootCand;
    vector<int> vec1(vec);
    int mx=mex(vec1);
    valueRootCand.pb(mx);
    vec1.pb(mx);
    valueRootCand.pb(mex(vec1));

    for (int valueChosen : valueRootCand) {
        vector<int> value_cpy(value);
        value_cpy[root]=valueChosen;
        vector<int> vec_cpy(vec);
        vec_cpy.pb(dfs(x,value_cpy));
        if (valueChosen==mex(vec_cpy)) {
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 33920
n = gets.chomp.to_i
length = []

for i in 0...n
        data = gets.chomp.to_s
        length[i] = data.split.map!{|x| x.to_i}.sort!
end

for i in 0...n
        if length[i][0] ** 2 + length[i][1] ** 2 == length[i][2] ** 2
                puts "YES"
        elsif
                puts "NO"
        end
end



Measured memory_bytes: 6872
#include <stdio.h>

int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x>=r&&x<=W-r&&y>=r&&y<=H-r){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1816
#include<iostream>
#include<vector>
#include <limits.h>
#include <algorithm>
using namespace std;
 
int main() {
	int W, H;
	cin >> W >> H;
	vector<unsigned long long> P(W);
	vector<unsigned long long> Q(H);
	for (int i = 0; i < W; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < H; i++) {
		cin >> Q[i];
	}
	sort(P.begin(), P.end());
	sort(Q.begin(), Q.end());
	int pi = 0;
	int qi = 0;
	int w = W + 1;
	int h = H + 1;
	unsigned long long cost = 0;
	while(true) {
		long long p = P[pi];
		long long q = Q[qi];
		if (p < q) {
			cost += p * h;
			w--; pi++;
		} else {
			cost += q * w;
			h--; qi++;
		}
		if (pi == W) {
			for (int i = qi; i < H; i++) {
				cost += Q[i];
			}
			break;
		}
		if (qi == H) {
			for (int i = pi; i < W; i++) {
				cost += P[i];
			}
			break;
		}
	}
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

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

    sort(a, a+n);

    int ans = n;
    for (int i = 1; i < n; i++) {
        if (a[i] > a[i-1] * 2) {
            ans = n - i;
        }
        a[i] += a[i-1];
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    ll m, v;
    int p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    sort(a.rbegin(), a.rend());
    show(a);
    auto check = [&](int x) -> bool{
        if(a[p-1] > a[x-1] + m)return false;
        ll V = v;
        V--;//a[x-1]
        V-= p - 1;//a[0]~a[p-2]
        V -= (n - x);//a[x]~a[n-1]
        if(V<= 0)return true;
        //a[p-1]~a[x-2]
        ll res = m * V;
        for(int i = x - 2;i >= p - 1 and i >= 0 and i < n; i--){
            res -= a[x - 1] + m - a[i];
        }
        return res <= 0;
    };
    int l = p;
    int r = n;
    if(check(n)){
        cout << n << endl;
        return 0;
    }
    while(r - l > 1){
        int mid = (l + r) / 2;
        if(check(mid)){
            l = mid;
        }else{
            r = mid;
        }
    }
    cout << l << endl;
    return 0;
    
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  bool f;
  string s, t;
  cin >> s >> t;
  REP(i, s.length()) {
    f = false;
    REP(j, s.length()) {
      if (s[j] != t[(j + i) % s.length()]) {
        f = true;
        break;
      }
    }
    if (!f) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main(void) {

    int n, d ;
    cin >> n >> d ;

    vector<vector<int>>zahyo(n, vector<int>(d)) ;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++)
            cin >> zahyo[i][j];
    } 

    double len ; 
    int cnt = 0 ;
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            len = 0 ;
            for (int k = 0; k < d; k++) {
                len += pow((zahyo[i][k] - zahyo[j][k]), 2) ;
            }
            len = sqrt(len) ;

            int lenI = int(len) ;
            if (len - lenI == 0)
                cnt++ ;
        }
    }
    cout << cnt ;

    return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=naive")
//#pragma GCC diagnostic ignored "-W"
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int h[100005];
int main(){
        int n;
        while(~getI(n)){
                int ans=0,now=0;
                F(i,0,n) getI(h[i]);
                h[n]=INF;
                F(i,0,n){
                        if(h[i]<h[i+1]){
                                ans=max(ans,now);
                                now=0;
                                continue;
                        }
                        now++;
                }
                printf("%d\n",ans);
        }
}

Measured memory_bytes: 640
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
X = max(A)
if K == 0:
    print(X)
    exit()
else:
    for i in range(1, math.ceil(math.log2(X)) + 5):
        B = []
        for a in A:
            b = math.ceil(a / X) - 1
            B.append(b)
        B_total = sum(B)
        if B_total > K:
            X += max(A) / pow(2, i)
        else:
            X -= max(A) / pow(2, i)
    print(math.ceil(X))

Measured memory_bytes: 31056
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		
		//????????£????????§??´??°?????????????????????
	    Scanner sc = new Scanner(System.in);
	    String s1 = sc.next();
	    int a = Integer.parseInt(s1);
	    String s2 = sc.next();
	    int b = Integer.parseInt(s2);
	    String s3 = sc.next();
	    int c = Integer.parseInt(s3);
	    int sum = 0;
	    
	    //??´??°a???b???c????????¶??????????????????????????????????????????a<=b??§??????????¢????
	    if(1 <= a && a <= 10000){
	    	if(1 <= b && b <= 10000){
	    		if(1 <= c && c <= 10000){
	    			if(a <= b){
	    					
	    			    //c?´???°???a??????b?????§?????????????????????????¨????
	    				for(int i = a; i <= b; i++){
	    					if(c % i == 0){
	    					    sum++;
	    					}
	    				}
	    				
	    				//?´???°?????°?????¨???
	    				System.out.println( sum );
	    			}
	    		}
	    	}
	    }
	}
}

Measured memory_bytes: 17288
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[100005];
ll M;
ll P[105];
ll X[105];

int main() {
	scanf("%lld", &N);
	ll sum = 0;
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		sum += arr[i];
	}
	ll sum1 = sum;
	scanf("%lld", &M);
	for(int i = 0; i < M; i++) {
		scanf("%lld %lld", &P[i], &X[i]);
	}
	for(int i = 0; i < M; i++) {
		sum = sum1;
		// cout << sum << " this";
		P[i] -= 1;
		// cout << P[i] << " this ";
		sum -= arr[P[i]];
		// cout <<
		// cout << sum << " this ";
		// arr[P[i]] = X[i];
		sum += X[i];
		printf("%lld\n", sum);
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

char s[105];
int idx;

pii calc(){
  int plus;
  if(s[idx]=='n'){
    plus=-90;
    idx+=5;
  } else {
    plus=90;
    idx+=4;
  }

  if(s[idx]=='\0') return mp(45+plus/2,1);

  else {
    pii p = calc();
    return mp(p.first*2+plus, p.second*2);
  }
}

int main(){
  while(true){
    scanf("%s", s);
    if(s[0]=='#') break;

    idx=0;
    pii res = calc();
    if(res.first%res.second==0) cout<<res.first/res.second<<endl;
    else cout<<res.first/2<<"/"<<res.second/2<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	k, n := scanInt(), scanInt()
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}

	ans := a[n-1] - a[0]
	for i := 1; i < n; i++ {
		ans = min(ans, a[i-1]-(a[i]-k))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int n,c;
  cin >> n >> c;
  vvint chan(30,vint(200000));
  rep(i,0,n){
    int s,t,c;
    cin >> s >> t >> c;
    s--;t--;c--;
    chan[c][s]++;
    chan[c][t]++;
    if(chan[c][s] == 2) chan[c][s] = 0;
    if(chan[c][s] == 2) chan[c][s] = 0;
  }
  vbool judge(c);
  int ans = 0;
  rep(i,0,200000){
    int tmp = 0;
    rep(m,0,c){
      if(chan[m][i] == 1){
        if(judge[m] == 0){
          tmp++;
          judge[m] = 1;
        }
        else{
          tmp++;
          judge[m] = 0;
        }
      }
      else if(judge[m] == 1) tmp++;
    }
    ans = max(ans,tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 48768
N = int(raw_input())
a = []
for i in range(N):
	a.append(raw_input())
#print a
for i in range(N):
	a[i] = int(a[i])
cnt = 0
trn = 0
while trn != 1:
	if trn == -2:
		cnt = -1
		break
	#print a

	hako = trn
	trn = a[trn] - 1
	a[hako] = -1
	cnt += 1
	
print cnt


Measured memory_bytes: 11460
#include<stdio.h>

int main(void)
{
	int i,n,l,sum=0,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&l);
		sum+=l;
		if(l>max)
			max=l;
	}
	if(sum-max*2>0)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9
const int MAXN = 100001;

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/


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

//-----Template---------
LL n;
LL t[1001];
LL a[1001];
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>t[i]>>a[i];
    }
    LL pastT,pastA;
    LL nowT=t[0],nowA=a[0];
    for (int i = 1; i < n; ++i) {
        pastT=nowT; pastA=nowA;
        if(t[i]==1 && a[i]==1){
            nowT=max(pastT,pastA);
            nowA=max(pastT,pastA);
        }else if(pastT<=t[i] && pastA<=a[i]){//最小はt[i],a[i]
            nowT=t[i]; nowA=a[i];
        }else if(t[i]<a[i]){//まずtをt[i]の倍数にして,次にa[i]をあわせる．now>=pastならOK．NGなら反対を試す．それでもNGならassert
            LL prod=pastT%t[i]==0? pastT/t[i] :(pastT/t[i] +1);
            nowT=t[i]*prod;
            nowA=nowT/t[i]*a[i];
            if(nowT>=pastT && nowA>=pastA)
                continue;
            prod=pastA%a[i]==0?pastA/a[i]:(pastA/a[i]+1);
            nowA=a[i]*prod;
            nowT=nowA/a[i]*t[i];
            if(nowT<pastT && nowA<pastA)
                throw std::runtime_error("んああ");
        }else{ //aが小さい
            LL prod=pastA%a[i]==0?pastA/a[i]:(pastA/a[i]+1);
            nowA=a[i]*prod;
            nowT=nowA/a[i]*t[i];
            if(nowT>=pastT && nowA>=pastA)
                continue;
            prod=pastT%t[i]==0? pastT/t[i] :(pastT/t[i] +1);
            nowT=t[i]*prod;
            nowA=nowT/t[i]*a[i];
            if(nowT<pastT || nowA<pastA)
                throw std::runtime_error("んああ");
        }
    }
    cout<<nowT+nowA<<endl;
}

Measured memory_bytes: 256
from operator import itemgetter
N = int(input())

lst = []
for i in range(N):
  dic = {}
  dic_i = {}
  s, p = map(str, input().split())
  dic['city'] = s
  dic['point'] = int(p)
  dic['index'] = i+1
  lst.append(dic)

a = sorted(lst, key=itemgetter('point'), reverse=True)
b = sorted(a, key=itemgetter('city'))

for i in b:
  print(i['index'])

Measured memory_bytes: 3064
N = int(input())
a_list = [int(x) for x in input().split(' ')]
a_list = list(filter(lambda x:x%2 == 0 and (x%3 != 0 and x%5 != 0), a_list))

if not a_list:
    print('APPROVED')
else:
    print('DENIED')

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

#define MAX 2000005

int A[MAX];
int H;

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

void maxHeapfy(int i) {
	int l = left(i);
	int r = right(i);
	int largest;

	if (l<H + 1 && A[l]>A[i])largest = l;
	else largest = i;
	if (r<H + 1 && A[r]>A[largest])largest = r;

	if (largest != i) {
		int temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		maxHeapfy(largest);
	}
}

void buildMaxHeap() {
	for (int i = H / 2; i > 0; i--) {
		maxHeapfy(i);
	}
}

void insert(int k) {
	A[++H] = k;
	if (H == 1)return;
	int c = H;
	int val = A[c];
	while (c > 1 && A[c/2] < val) {
		A[c] = A[c / 2];
		c /= 2;
	}
	A[c] = val;
}

int extractMax() {
	if (H < 1)return -1;
	int ret = A[1];
	A[1] = A[H];
	H--;
	maxHeapfy(1);
	return ret;
}

int main() {
	H = 0;
	while (true) {
		char buf[10];
		cin >> buf;
		if (buf[0] == 'i') {
			int k;
			cin >> k;
			insert(k);
		}
		else if (buf[1] == 'x') {
			cout << extractMax() << endl;
		}
		else break;
	}
	return 0;
}


Measured memory_bytes: 6992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		String s = sc1.next();
		int w = sc1.nextInt();
		String ans = "";

		for ( int i = 0 ; i < s.length() ; i += w) {
			ans += s.charAt(i);
		}

		System.out.println(ans);

		sc1.close();
	}

}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n, k;
	vector<int> minus;
	vector<int> plus;
	minus.push_back(0);
	plus.push_back(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++){
		int x;
		cin >> x;
		if (x < 0) minus.push_back(-x);
		if (x > 0) plus.push_back(x);
		if (x == 0) k--;
	}
	sort(minus.begin(), minus.end());

	int ans = MOD;
	for (int i = 0; i <= min((int)minus.size()-1, k); i++){
		if (k-i < (int)plus.size()) ans = min(ans, minus[i] + plus[k-i] + min(minus[i], plus[k-i]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1020
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int main()
{
  char S[1002], T[1002];
  int cnt =0, m =1001;
  scanf("%s", S);
  scanf("%s", T);

  int lens = strlen(S), lent = strlen(T);

  for(int i = 0; i<=lens - lent; ++i)
  {
    for(int j = i; j<lent + i; j++)
    {
      if(S[j] != T[j-i])
        cnt++;
    }
    m = min(cnt, m);
    cnt = 0;
  }

  printf("%d", m);

}

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

int main() {
  map<string, int> m;
  int n;
  cin >> n;
  rep(i, n) {
    string s;
    cin >> s;
    m[s]++;
  }

  auto output = [&](string str) {
    cout << str << " x " << m[str] << endl;
  };

  output("AC");
  output("WA");
  output("TLE");
  output("RE");

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define dcout cout<<fixed<<setprecision(20)
#define Accepted_MAGIC cin.tie(0);ios::sync_with_stdio(false)

// typedef long long ll;
using Real = long double;
#define int long long

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
constexpr Real eps = 1e-9, pi = acos(-1);

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

signed main(void){
  Accepted_MAGIC;
  
  int H, W, K; string S[10];
  cin >> H >> W >> K;
  int cnt[10][1010] = {};
  REP(i, H) {
    cin >> S[i];
    REP(j, W){
      cnt[i][j+1] += cnt[i][j];
      if(S[i][j] == '1') cnt[i][j+1]++;
    }
  }
  int ans = BIG;
  REP(bit, (1<<(H-1))){
    int anspre = __builtin_popcount(bit);
    int left = 0;
    REP(j, W){
      int num = 0;
      bool greater = 0;
      REP(i, H){
        num += cnt[i][j+1]-cnt[i][left];
        if((bit>>i) & 1){
          greater |= (num > K);
          num = 0;
        }
      }
      greater |= (num > K);
      if(greater) {
        if(left == j){
          anspre = VERYBIG;
          break;
        }
        anspre++; left = j;
      }
    }
    chmin(ans, anspre);
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    ll A,B,N;

    cin >> A >> B >> N;
    
    ll x = B-1;
    if(x > N){
        x = N;
    }
    cout <<  (A*x)/B - A * (x/B);
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define MAX 10
#define For(i, a, b) for( int i = (a); i < (b); i++ )
#define ll long long
using namespace std;

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

    double l;
    cin>>l;

    double x = l/3.0;

    cout<<fixed<<setprecision(6)<<(x*x*x)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N;
  cin >> N;
  vector<ll> b(N),ans(N,0);
  rep(i,N) cin >> b.at(i);
  rep(j,N){
    ll t=1,x=-1;
    for(ll i=0;i<N;i++){
      if(b.at(i)==t){
        ans.at(N-1-j)=max(ans.at(N-1-j),t);
        x=max(x,i);
      }
      if(b.at(i)!=0){
        t++;
      }
    }
    if(x==-1){
      cout << -1 << endl;
      return 0;
    }
    b.at(x)=0;
  }
  rep(i,N){
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define int unsigned int
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int P,D,LL;
inline void upd(R int &x,R int y){x+=y,x-=P*D*(x>>30),x%=P;}
inline int add(R int x,R int y){return x+=y,x-=P*D*(x>>30),x%=P;}
inline int mul(R int x,R int y){return 1ull*x*y-1ull*x*y/P*P;}
int ksm(R int x,R int y){
    R int res=1;
    for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
    return res;
}
const int N=105;
int f[N][N][N][2],coef[N][N][N][2],bn[N][N];
int n,m,L,ret,cp;
signed main(){
//	freopen("testdata.in","r",stdin);
    scanf("%u%u%u%u",&n,&m,&L,&P);
    D=(1<<30)/P;
    fp(i,0,max(n,m)){
        bn[i][0]=1;
        fp(j,1,i)bn[i][j]=add(bn[i-1][j],bn[i-1][j-1]);
    }
    fp(k,1,L)fp(i,0,m){
        cp=mul(ksm(L-k+1,i),add(ksm(k,m-i),P-ksm(k-1,m-i)));
        ret=1;
        fp(j,0,n)coef[k][i][j][0]=ret,ret=mul(ret,cp);
    }
    fp(k,1,L)fp(i,0,n){
        cp=mul(add(ksm(L-k+1,i),P-ksm(L-k,i)),ksm(k,n-i));
        ret=1;
        fp(j,0,m)coef[k][i][j][1]=ret,ret=mul(ret,cp);
    }
    f[1][0][0][0]=1;
    fp(k,1,L)fp(i,0,n)fp(j,0,m){
        ret=f[k][i][j][0];
        fp(l,0,n-i)upd(f[k][i+l][j][1],1ull*ret*bn[n-i][l]%P*coef[k][j][l][0]%P);
        ret=f[k][i][j][1];
        fp(l,0,m-j)upd(f[k+1][i][j+l][0],1ull*ret*bn[m-j][l]%P*coef[k][i][l][1]%P);
    }
    printf("%u\n",f[L+1][n][m][0]%P);
    return 0;
}


Measured memory_bytes: 18048
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<30;
vector<int> A;
const int mod = 1e9+7;

bool ok(int N) {
  if(N % 2 == 1) {
    for(int i = 0; i < N; i++) {
      if(A[i] != (i+1)/2*2) return false;
    }
    return true;
  } else {
    for(int i = 0; i < N; i++) {
      if(A[i] != i/2*2+1) return false;
    }
    return true;
  }
}

int main() {
  int N; cin >> N;
  A.resize(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  if(!ok(N)) {
    cout << 0 << endl;
    return 0;
  } else {
    long long ans = 1;
    for(int i = 0; i < N/2; i++) {
      ans *= 2;
      ans %= mod;
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    int s[n+1];
    s[0] = 0;
    int a=1, b=1;
    for(int i = 1; i <= n; i++){
        while(i >= a*6){
            a = a*6;
        }
        while(i >= b*9){
            b = b*9;
        }
        s[i] = min(s[i-a]+1, s[i-b]+1);
    }
    cout << s[n] << endl;
    return 0;
}

Measured memory_bytes: 640
s=input()
for _ in range(int(input())):
 a=input().split()
 if a[0]=='print':print(s[int(a[1]):int(a[2])+1])
 else:
  t=s[0:int(a[1])]
  t+=s[int(a[1]):int(a[2])+1][::-1]if'reverse'==a[0]else a[3]
  s=t+s[int(a[2])+1:]

Measured memory_bytes: 5616
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

template <class T1, class T2>
struct pair_first_less {
	bool operator()(const std::pair<T1, T2> &x, const std::pair<T1, T2> &y) const {
		return x.first < y.first;
	}
};

template <class T1, class T2>
struct pair_second_less {
	bool operator()(const std::pair<T1, T2> &x, const std::pair<T1, T2> &y) const {
		return x.second < y.second;
	}
};

void input(std::vector< std::pair<int, int> > *t, int n)
{
	for (int i = 0; i < n; ++i) {
		int h0, m0, s0, h1, m1, s1;
		scanf("%02d:%02d:%02d %02d:%02d:%02d", &h0, &m0, &s0, &h1, &m1, &s1);
		const int t0 = (h0 * 60 + m0) * 60 + s0;
		const int t1 = (h1 * 60 + m1) * 60 + s1;
		t->push_back(std::pair<int, int>(t0, t1));
	}
}

int answer(const std::vector< std::pair<int, int> > &t)
{
	std::vector< std::pair<int, int> > f;	// 
	for (std::vector< std::pair<int, int> >::const_iterator it = t.begin(); it != t.end(); ++it) {
		if (it->first > it->second) { continue; }
		f.push_back(std::pair<int, int>(it->first, 1));
		f.push_back(std::pair<int, int>(it->second, -1));
	}
	std::sort(f.begin(), f.end(), pair_second_less<int, int>());
	std::stable_sort(f.begin(), f.end(), pair_first_less<int, int>());
	int n_max = 0, n = 0;
	for (std::vector< std::pair<int, int> >::iterator it = f.begin(); it != f.end(); ++it) {
		n += it->second;
		if (n > n_max) { n_max = n; }
	}
	return n_max;
}

int main()
{
	int n;
	while (scanf("%d", &n), n > 0) {
		std::vector< std::pair<int, int> > t;
		input(&t, n);
		printf("%d\n", answer(t));
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Queue<String> name_queue = new ArrayDeque<>();
        Queue<Integer> queue = new ArrayDeque<>();
        int n = sc.nextInt();
        int q = sc.nextInt();
        for(int i = 0 ; i < n ; i++){
            name_queue.add(sc.next());
            queue.add(sc.nextInt());
        }
        int count_time = 0;
        while(true){
            String name = name_queue.poll();
            if(queue.peek() == null)
                break;
            int num = queue.poll();
            if(num <= q){
                count_time += num;
                System.out.println(name + " " + count_time);
            }
            else{
                count_time += q;
                num -= q;
                queue.add(num);
                name_queue.add(name);
            }
        }
    }
}


Measured memory_bytes: 71608
from collections import deque
N = int(input())

data = {}
inputData = []
edges = {}
maxColor = 0
for i in range(N-1):
    a, b = map(int, input().split())
    data[(a, b)] = 0
    inputData.append((a, b))
    if a not in edges:
        edges[a] = []
    if b not in edges:
        edges[b] = []
    edges[a].append(b)
    edges[b].append(a)
    maxColor = max(maxColor, len(edges[a]))

queue = deque([(1, 0)])

while(len(queue)):
    q, c = queue.popleft()
    k = 0
    for v in edges[q]:
        a = min(q,v)
        b = max(q,v)
        if(data[(a, b)]) != 0:
            continue
        k += 1
        data[(a, b)] = c+k
        queue.append((v, c+k))
print(maxColor)
for i in range(N-1):
    print((data[inputData[i]]-1)%maxColor+1)

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

int main() {
    string T, S;
    int sum;
    cin >> T >> S;

 sum =0;
 if(T.at(0)== S.at(0)){
 sum = sum +1;
}
 if(T.at(1)== S.at(1)){
 sum = sum +1;
}
 if(T.at(2)== S.at(2)){
 sum = sum +1;
}

cout << sum << endl;
}

Measured memory_bytes: 256