akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
using namespace std;
char Map[110][110];
int n, m,sum;
void dfs(int x, int y,char key)
{
	Map[x][y] = '1';
	int dx[] = { 1,-1,0,0 };
	int dy[] = { 0,0,-1,1 };
	for (int i = 0; i < 4; i++)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (nx >= 0 && nx < n&&ny >= 0 && ny < m)
		{
			if (Map[nx][ny] == key)
				dfs(nx, ny,key);
		}
	}
}
int main()
{
	//freopen("C:\\Users\\国民党\\Desktop\\text.txt", "r", stdin);
	while (scanf("%d%d", &n, &m), n + m)
	{
		sum = 0;
		for (int i = 0; i < n; i++)
			scanf("%s", &Map[i]);
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				if (Map[i][j] != '1')
				{
					sum++;
					dfs(i, j,Map[i][j]);
				}
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 4212
N, P = map(int, input().split())
S = input()
if P == 2:
    counter = 0
    for i in range(len(S)):
        if S[i] in ['2', '4', '6', '8', '0']:
            counter += i + 1
    print(counter)
elif P == 5:
    counter = 0
    for i in range(len(S)):
        if S[i] in ['5', '0']:
            counter += i + 1
    print(counter)
else:
    list_a = [0] * P
    list_a[0] += 1
    counter = 0
    temp = 0
    power = 1
    for i in range(N):
        power *= 10
        power %= P
        temp += power * int(S[N-i-1])
        temp %= P
        counter += list_a[temp]
        list_a[temp] += 1
    print(counter)



Measured memory_bytes: 3500
io = STDIN
def cv(ar)    #ar: [r,r,l]
  size=ar.size
  r=ar.count("R")
  l=size-r
  if size.even?
    [0]*(r-1)+[ar.size/2,ar.size/2]+[0]*(l-1)
  else
    min=[l,r].min
    [0]*(r-1) +
    if min.odd? && r>l ||
       min.even? && r<l
      [size/2,size-size/2]
    else
      [size-size/2,size/2]
    end +
    [0]*(l-1)
  end
end
str=io.gets.chomp
chnk=str.split(//).chunk_while do |a,b|
  a!="L" || b!='R'
end
puts chnk.map{|ar|cv(ar)}.flatten.join(" ")


Measured memory_bytes: 18556
#include <bits/stdc++.h>
#define rep(i , x , y) for(register int i = (x) , _## i = ((y) + 1) ; i < _## i ; i ++)
#define Rep(i , x , y) for(register int i = (x) , _## i = ((y) - 1) ; i > _## i ; i --)
using namespace std ;
#define int long long
using ll = long long ;
using pii = pair < int , int > ;
const static int _ = 1 << 20 ;
char fin[_] , * p1 = fin , * p2 = fin ;
inline char gc() { return (p1 == p2) && (p2 = (p1 = fin) + fread(fin , 1 , _ , stdin) , p1 == p2) ? EOF : * p1 ++ ; }
inline int read() {
	bool sign = 1 ; char c = 0 ; while(c < 48) ((c = gc()) == 45) && (sign = 0) ;
	int x = (c & 15) ; while((c = gc()) > 47) x = (x << 1) + (x << 3) + (c & 15) ;
	return sign ? x : -x ;
}
template < class T > void print(T x , char c = '\n') {
	(x == 0) && (putchar(48)) , (x < 0) && (putchar(45) , x = -x) ;
	static char _st[100] ; int _stp = 0 ;
	while(x) _st[++ _stp] = x % 10 ^ 48 , x /= 10 ;
	while(_stp) putchar(_st[_stp --]) ; putchar(c) ;
}
template < class T > void cmax(T & x , T y) { (x < y) && (x = y) ; }
template < class T > void cmin(T & x , T y) { (x > y) && (x = y) ; }
signed main() {
#ifdef _WIN64
	freopen("testdata.in" , "r" , stdin) ;
#endif
	int n = read() , x , y = 0 , ans = 0 ;
	while(n --) {
		x = read() ;
		if(x == y + 1) y ++ ;
		else ans ++ ;
	}
	if(y) print(ans) ;
	else print(-1) ;
	return 0 ;
}

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

int main(){
  int N ; 
  cin >> N;  
  int ans = 0 ; 
  
  
  for(int i = 1 ; i <= N ; i = i + 2 ){ 
    int cnt=0 ;
    for(int j=1; j <= i ; j++ ){
      if( i % j == 0 ){
        cnt++ ; 
      }
    }
    if(cnt == 8 ) ans++; 
  }
  cout << ans << endl ; 
}

Measured memory_bytes: 3604
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
void main()
{
    long n, k;
    scan(n, k);
    auto h = aryread();
    auto h_so = sort(h);
    // writeln(h_so);
    if (h.length <= k)
    {
        writeln(0);
        return;
    }
    if (k == 0)
    {
        writeln(sum(h));
        return;
    }
    foreach (i; 0 .. k)
    {
        h_so[(n - 1) - i] = 0;
    }
    writeln(sum(h_so));

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 12612
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

Node treeSearch(Node u, int k){
  while(u != NIL){
  if(u->key == k) return u;
  else if(u->key > k) u = u->left;
  else u = u->right;
  }
  return NIL;
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
     if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
     } 
     else if ( com[0] == 'i' ){
       scanf("%d", &x);
       insert(x);
     } else if ( com[0] == 'p' ){
       inorder(root);
       printf("\n");
       preorder(root);
      printf("\n");
     } 
  }
  
  return 0;
}



Measured memory_bytes: 20484
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, C = mi()
D = li2(C)
S = li2(N)

table = dp2(0, C, 3)
'''
#for num in range(3):
    #for start in range(num, N, 3):
        for color in range(C):
            i = 0
            j = start
            print(i, j)
            while True:
                table[num][color] += D[S[i][j]-1][color]
                if j < 1 or i >= N:
                    break
                j -= 1
                i += 1
'''
for i in range(N):
    for j in range(N):
        for color in range(C):
            table[(i+j)%3][color] += D[S[i][j]-1][color]

ans = float('inf')
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or j == k or k == i:
                continue
            ans = min(ans, table[0][i] + table[1][j] + table[2][k])

print(ans)

Measured memory_bytes: 76576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
    cin >> n;
  int a, l=10000, r=0;
    for(int i=0; i<n; i++){
      cin >> a;
      l = min(l, a);
      r = max(r, a);
    }
    cout << r-l << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		long[] a = new long[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextLong();
		}

		for(int i = 0; i < Q; i++) {
			long que=sc.nextLong();
			long cnt = 0;
			long sum = 0;
			int right = 0;
			for(int left = 0; left < N; left++) {
				while(right < N && sum + a[right] <= que) {
					sum += a[right];
					right++;
				}
				cnt += (right - left);
				//System.out.println("†"+(right-left)+" "+(right+" "+left));
				if(left == right) {
					right++;
				}else {
					sum -= a[left];
				}
			}
			System.out.println(cnt);
		}
	}
}


/*
class dsl3c{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int Q=sc.nextInt();
		long[] wa=new long[N+1];
		for(int i=1; i<=N; i++) {
			wa[i]=sc.nextInt();
		}
		wa[0]=0;
		for(int i=1; i<=N; i++) {
			wa[i]=wa[i]+wa[i-1];		//累積和
		}
		for(int jj=0; jj<Q; jj++) {
			long sum=sc.nextLong();

			long kotae=0;
			int right=1;

			for(int left=0; left<N; left++) {
				if(left>right) {
					right=left;
				}
				while(wa[right]-wa[left]>=sum) {
					right++;
				}
				kotae+=right-right+1;
			}
			System.out.println(kotae);
		}
	}
}

*/

/*

import java.util.Scanner;

class dsl3c{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int Q=sc.nextInt();
		long[] wa=new long[N+1];
		for(int i=1; i<=N; i++) {
			wa[i]=sc.nextInt();
		}
		wa[0]=0;
		for(int i=1; i<=N; i++) {
			wa[i]=wa[i]+wa[i-1];		//累積和
		}
		for(int jj=0; jj<Q; jj++) {
			long sum=sc.nextLong();

			long kotae=0;

			for(int i=0; i<N; i++) {		//いちばんひだり
				int counter=0;
				while(true) {
					if(i+counter>N) {
						kotae+=counter-1;
						break;
					}
					else {
						if(wa[i+counter]-wa[i]<=sum) {
							counter++;
						}
						else if(wa[i+counter]-wa[i]>=sum) {
							if(wa[i+counter]-wa[i]>=sum) {
								kotae+=(counter-1);
								break;
							}
							else {
								kotae+=(counter-2);
								break;
							}
						}
					}
				}
			}
			System.out.println(kotae);
		}
	}
}

O(N^2)解法

*/


Measured memory_bytes: 68920
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  vi a(3);
  cin >> a;
  swap(a[0], a[1]);
  swap(a[0], a[2]);
  cout << a << endl;
  return (0 ^ _ ^ 0);
}



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

using namespace std;

#define MAX 334
#define MAX_L 17
#define INF 1e9

struct edge{
  int to,cost;
};

struct State{
  int cost,v,S;
  bool operator < (const State &s)const{
    return cost > s.cost;
  }
};

int N,M,L,S,T,restv[MAX_L],reste[MAX_L];
vector<edge> G[MAX_L];
int dist[1<<MAX_L][MAX_L];

string bit(int S){
  string res;
  for(int i = 0 ; i < L ; i++){
    if((S >> i) & 1) res += '1';
    else res += '0';
  }
  return res;
}

int dijkstra(){
  priority_queue<State> Q;
  Q.push((State){0,L,0});
  int ans = 0;
  for(int i = 0 ; i < (1<<L) ; i++){
    for(int j = 0 ; j <= L ; j++){
      dist[i][j] = INF;
    }
  }
  dist[0][L] = 0;
  while(!Q.empty()){
    State s = Q.top(); Q.pop();
    int v = s.v;
    if(s.cost <= T && v == L){
      ans = max(ans,__builtin_popcount(s.S));
    }
    if(s.cost >= T){ continue; }
    if(dist[s.S][v] < s.cost) continue;
    if(v != L){
      if(!((s.S >> v) & 1)){
        int next = s.S | (1<<v);
        if(dist[s.S][v] + reste[v] < dist[next][v]){
          dist[next][v] = dist[s.S][v] + reste[v];
          Q.push((State){dist[next][v],v,next});
        }
      }
    }
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      edge &e = G[v][i];
      if(dist[s.S][v] + e.cost < dist[s.S][e.to]){
        dist[s.S][e.to] = dist[s.S][v] + e.cost;
        Q.push((State){dist[s.S][e.to],e.to,s.S});
      }
    }
  }
  return ans;
}

int main(){
  while(cin >> N >> M >> L >> S >> T, N){
    int d[MAX][MAX];
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
        if(i == j){
          d[i][j] = 0;
        }else{
          d[i][j] = INF;
        }
      }
    }
    for(int i = 0 ; i < MAX_L ; i++){
      G[i].clear();
    }
    S--;
    for(int i = 0 ; i < M ; i++){
      int a,b,c;
      cin >> a >> b >> c;
      a--; b--;
      d[a][b] = d[b][a] = c;
    }
    for(int k = 0 ; k < N ; k++){
      for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
          d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
        }
      }
    }
    int restv[MAX_L];
    for(int i = 0 ; i < L ; i++){
      cin >> restv[i] >> reste[i];
      restv[i]--;
    }
    restv[L] = S; reste[L] = 0;
    for(int i = 0 ; i <= L ; i++){
      for(int j = i+1 ; j <= L ; j++){
        int time = d[restv[i]][restv[j]];
        if(time == INF) continue;
        G[i].push_back((edge){j,time});
        G[j].push_back((edge){i,time});
      }
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

Measured memory_bytes: 29580
#include <cstdio>
#include <iostream>

using namespace std;

int A[200];
int n, q, m;

bool solve(int i, int m)
{
  if(m == 0) return true;
  if(i >= n) return false;
  return solve(i + 1, m) || solve(i + 1, m - A[i]);
}

int main()
{
  cin >> n;
  for(int i = 0; i < n; i++) cin >> A[i];
  cin >> q;
  for(int i = 0; i < q; i++)
  {
    cin >> m;
    cout << (solve(0, m) ? "yes" : "no") << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  string ans="No";
  cin >> S >> T;
  string a,b;
  int s=S.size();
  int i,j,n,q;
  for(i=0;i<s;i++){
    if(S==T){ans="Yes";}
    S=S.substr(1)+S.at(0);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)throws Exception {
		BufferedReader br = new BufferedReader ( new InputStreamReader(System.in));
		String [] input = br.readLine().split(" ");
		long A = Long.parseLong(input[0]);
		long B = Long.parseLong(input[1]);
		long C = Long.parseLong(input[2]);
		long defineA= A;
		long defineB = B;
		long defineC = C;
		long result = 0;
		/*if(Even(A,B,C)){
			result = -1;
		}else if(A+B+C == 3) {
			result = 0;
		}else {*/
			while(true) {
				if(Even(A) || Even(B) || Even(C)) {
					break;
				}
				long A2 = A/2;
				long B2 = B/2;
				long C2 = C/2;
				A = B2 + C2;
				B = A2 + C2;
				C = A2 + B2;
				result++;
				if(defineA == A && defineB == B && defineC == C) {
					result = -1;
					break;
				}
			}
		//}
		System.out.println(result);
	}
	private static boolean Even(long A,long B,long C) {
		return (A % 2!=0) && (B % 2!=0) && (C % 2!=0);
	}
	private static boolean Even(long var) {
		return (var % 2!=0);
	}

}

Measured memory_bytes: 22484
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int __int128
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	long long X, K, D;
	int x, k, d;
	int nx = 0;
	
	cin>>X>>K>>D;
	
	x = X;
	k = K;
	d = D;
	
	if(x < 0) x *= -1;
	
	if(x - d * k >= 0) {
		// cout<<"x"<<endl;
		cout<<(long long)(x - d * k)<<endl;
	} else {
		int con = x / d;
		
		// int con2 = (x + d - 1)/ d;
		
		// cout<<"con = "<<(long long)con<<endl;
		if((k - con)%2 == 0) {
			cout<<abs((long long)(x - con * d))<<endl;
		} else {
			cout<<((long long)((con + 1) * d - x))<<endl;
		}
	}
	
	
	return 0;
}

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

using namespace std;

struct edge {
    int w, a, b;
};

struct union_find {
    vector<int> par;

    union_find(int n) {
        par.resize(n, -1);
    }

    int find(int i) {
        if (par[i] < 0) return i;
        else return par[i] = find(par[i]);
    }

    void merge(int i, int j) {
        int pi = find(i);
        int pj = find(j);

        if (pi == pj) return;

        if (par[pi] < par[pj]) {
            par[pj] = pi;
        } else if (par[pi] > par[pj]) {
            par[pi] = pj;
        } else {
            par[pj] = pi;
            par[pi]--;
        }
    }
};

int main() {
    int N;
    scanf("%d", &N);

    vector<int> x(N), y(N);
    vector<int> by_x(N), by_y(N);
    for (int i = 0; i < N; ++i) {
        scanf("%d %d", &x[i], &y[i]);
        by_x[i] = i;
        by_y[i] = i;
    }

    sort(by_x.begin(), by_x.end(), [&](int a, int b) {
        return x[a] < x[b];
    });
    sort(by_y.begin(), by_y.end(), [&](int a, int b) {
        return y[a] < y[b];
    });

    vector<edge> edges;
    for (int i = 0; i < N - 1; ++i) {
        edges.push_back({x[by_x[i + 1]] - x[by_x[i]], by_x[i], by_x[i + 1]});
        edges.push_back({y[by_y[i + 1]] - y[by_y[i]], by_y[i], by_y[i + 1]});
    }
    sort(edges.begin(), edges.end(), [](edge a, edge b) {
        return a.w < b.w;
    });

    union_find uf(N);

    int cost = 0;
    for (int i = 0; i < edges.size(); ++i) {
        if (uf.find(edges[i].a) != uf.find(edges[i].b)) {
            cost += edges[i].w;
            uf.merge(edges[i].a, edges[i].b);
        }
    }

    printf("%d\n", cost);

    return 0;
}


Measured memory_bytes: 6516
N, M = map(int, input().split())
path = [set() for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    path[a-1].add(b-1)
    path[b-1].add(a-1)
visited = [0] * N

ans = 1
for u in range(N):
    if visited[u] == 1:
        continue
    curr = 1
    visited[u] = 1
    next_u = path[u]
    while next_u:
        v = next_u.pop()
        if visited[v] == 1:
            continue
        visited[v] = 1
        curr += 1
        for w in path[v]:
            if visited[w] == 0:
                next_u.add(w)
    ans = max(ans, curr)

print(ans)

Measured memory_bytes: 77724
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        l: [usize; n],
    }
    let mut count = 0;
    for k in 0..n {
        for j in 0..k {
            for i in 0..j {
                let mut edges = vec![l[i], l[j], l[k]];
                edges.sort();
                edges.dedup();
                if edges.len() == 3 && edges[0] + edges[1] > edges[2] {
                    count += 1;
                }
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
int main(){
 int x;
 cin>>x;
  if( x>=1800 && x<2000)
      cout<<"1";
     
    else if(x>=1600 && x<1800)
      cout<<"2";
         else  if(x>=1400 && x<1600)
          cout<<"3";
      
else if(x>=1200 && x<1400)
      cout<<"4";
      else if( x>=1000 && x<1200)
      cout<<"5";
     else if( x>=800 && x<1000)
      cout<<"6";
      else if(x>=600 && x<800)
      cout<<"7";
      else if(x>=400 && x<600)
      cout<<"8";
      
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int main() {
  IOS;
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double anglea = h * 30.0 + (m / 60.0) * 30.0;
  double angleb = m * 6.0;
  double cc = sqrt(
      abs(a * a + b * b -
          2.0 * a * b *
              cos((angleb - anglea) * 3.14159265358979323846264338 / 180.0)));

  cout << fixed << setprecision(20) << cc << endl;
}


Measured memory_bytes: 4164
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,m,k,ans=orz,d[805][805],sx,sy;
queue<int> qx,qy;
char c[805][805];
int main(){
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            scanf(" %c",c[i]+j);
            if(c[i][j]=='S')c[i][j]='.',sx=i,sy=j;
        }
    }
    memset(d,-1,sizeof(d));
    d[sx][sy]=0,c[sx][sy]='@';
    qx.push(sx),qy.push(sy);
    while(!qx.empty()){
        int x=qx.front(),y=qy.front();
        qx.pop(),qy.pop();
        if(x>1&&c[x-1][y]=='.'){
            d[x-1][y]=d[x][y]+1;
            qx.push(x-1),qy.push(y);
            c[x-1][y]='@';
        }
        if(y>1&&c[x][y-1]=='.'){
            d[x][y-1]=d[x][y]+1;
            qx.push(x),qy.push(y-1);
            c[x][y-1]='@';
        }
        if(x<n&&c[x+1][y]=='.'){
            d[x+1][y]=d[x][y]+1;
            qx.push(x+1),qy.push(y);
            c[x+1][y]='@';
        }
        if(y<m&&c[x][y+1]=='.'){
            d[x][y+1]=d[x][y]+1;
            qx.push(x),qy.push(y+1);
            c[x][y+1]='@';
        }
    }
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if(d[i][j]!=-1&&d[i][j]<=k){
                ans=min(ans,i-1);
                ans=min(ans,j-1);
                ans=min(ans,n-i);
                ans=min(ans,m-j);
            }
        }
    }
    if(ans)ans=(ans-1)/k+1;
    printf("%d\n",ans+1);
    //system("pause");
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
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 namespace std;

//power_mod
inline int Pow_mod(int x, int pow){
    if(pow==0) return 1;
    int a=Pow_mod(x, pow/2);
    a=a*a%mod;
    if(pow%2==1) a*=x;
    return a%mod;
}

//factorial_mod
int* fact_mod;
inline void init_fact_mod(int x){
    fact_mod = new int[x];
    fact_mod[0]=1;
    rep(i,x-1)fact_mod[i+1]=fact_mod[i]*(i+1)%mod;
}

//permutation_mod
inline int nPr_mod(int n, int r){
    return fact_mod[n]*Pow_mod(fact_mod[n-r]%mod, mod-2)%mod;
}

//combination_mod
inline int nCr_mod(int n, int r){
    return fact_mod[n]*Pow_mod(fact_mod[n-r]*fact_mod[r]%mod, mod-2)%mod;
}

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int N,a,b,c; cin>>N>>a>>b>>c;
    int A=a*Pow_mod(a+b,mod-2)%mod;
    int B=b*Pow_mod(a+b,mod-2)%mod;
    int C=100*Pow_mod(100-c,mod-2)%mod;

    init_fact_mod(200010);
    int ans=0;
    for(int i=N; i<N*2; i++){
        int tmp=((Pow_mod(A,N)*Pow_mod(B,i-N)%mod+Pow_mod(B,N)*Pow_mod(A,i-N)%mod)%mod)*nCr_mod(i-1,N-1)%mod;
        (ans+=(tmp*i%mod)*C%mod)%=mod;
    }
    cout<<ans<<endl;
    return 0;

}

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

int main(){
  string s;
  cin >> s;
  
  int ex = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'o') ex++;
  }
  
  cout << 700 + 100 * ex << endl;
  
  return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  long long n, m;
  cin >> n >> m;

  if (n % 2 == 1) {
    for (int i = 1; i <= m; ++i) {
      cout << i << ' ' << (n - i + 1) << '\n';
    }
  } else {
    for (int i = 1; i <= m; ++i) {
      int j = n - i + 1;
      if (i > n / 4) {
        cout << i << ' ' << j - 1 << '\n';
      } else {
        cout << i << ' ' << j << '\n';
      }
    }
  }
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> num(N);

    rep(i, N) {
        cin >> num[i];
    }

    int ans = 1001001001;

    for(int i = -100; i < 101; i++) {
        int sum = 0;
        rep(j, N) {
            sum += (num[j] - i) * (num[j] - i);
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
const val YES = "YES"
const val NO = "NO"
fun solve(X: Long){
    val x = X.toInt()
    when(x){
        7, 5, 3 -> {println(YES)}
        else -> {println(NO)}
    }
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val X = sc.next().toLong()
    solve(X)
}



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

int main() {
  int N;
  cin >> N;

  int x = 0;

  for (int i = 0; i < N; i++){
    string s;
    cin >> s;

    if(s == "Y"){
      x++;
    }
  }

  if (x == 0){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;
typedef long long ll;

int main() {

    int N;
    cin >> N;
    ll sum = 0;
    map<ll, ll> m;
    rep(i,N) {
        ll A;
        cin >> A;
        sum += A;
        if (m.find(A) != m.end()) m[A]++;
        else m.emplace(A, 1);
    }

    int Q;
    cin >> Q;
    rep(i,Q) {
        ll B, C;
        cin >> B >> C;
        if (m.find(B) != m.end()) {
            sum -= m[B] * B;
            sum += m[B] * C;
            if (m.find(C) != m.end()) m[C] += m[B];
            else m.emplace(C, m[B]);
            m.erase(B);
        }
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 7456
// Problem : C - Step
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vint vector<int>
#define sint set<int>
#define mint map<int,int>
#define pint pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void solve(){
	input(arr,n);
	// stack<int>s;
	int ans=0;
	for(int i=1;i<n;i++){
		if(arr[i]<arr[i-1]){
			ans+=abs(arr[i-1]-arr[i]);
			arr[i]=arr[i-1];
		}
		/*while(!s.empty() && arr[s.top()]<arr[i])s.pop();
		if(!s.empty())ans+=abs(arr[s.top()]-arr[i]);
		s.push(i);*/
	}	
	pp(ans);
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 5160
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>

#define ll long long int

using namespace std;

const int INF = (1<<30) - 1;

const int MAX_N = 20;
const int MAX_K = 10;
const int MAX_S = 155;

int dp[MAX_N+1][MAX_K+1][MAX_S+1];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    dp[0][0][0] = 1;
    for(int n=0; n<=MAX_N; n++){
        for(int k=0; k<=MAX_K; k++){
            for(int s=0; s<=MAX_S; s++){
                if(n-1>=0 && s-k>=0){
                    if(k-1>=0)
                        dp[n][k][s] += dp[n-1][k-1][s-k];
                    dp[n][k][s] += dp[n-1][k][s-k];
                }
            }
        }
    }
    int N, K, S;
    while(cin>>N>>K>>S, N|K|S){
        cout << dp[N][K][S] << endl;
    }
    
    return 0;
}

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

class Main{
  static public void main(String args[]){
    Integer N,K,count = 0;
    Scanner sc =new Scanner(System.in);
    N = sc.nextInt();
    K = sc.nextInt();
    int vec[] = new int[N];
    for(int i = 0; i < N; i++){
      vec[i] = sc.nextInt();
    }
    Arrays.sort(vec);
    for(int i = 0; i < N; i++){
      if(vec[i] >= K){
        count ++;
      }
    }
    System.out.print(count);
  }
}


Measured memory_bytes: 52220
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb emplace_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL))
int main()
{
     ll n;
     cin>>n;
     string s;
     cin>>s;
     ll ans = 0;
     for(ll i=0;i<n;i++)
     {
         while(i<n-1 && s[i]==s[i+1]) i++;
         ans++;
     }
     cout<<ans;
}

Measured memory_bytes: 512
// let coding = begin

#include<bits/stdc++.h>

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

using namespace std;
const ll MAX = 1e12+2;
const int INF = 99999999;
const int MIN = -1e9;
const int N = 5005;
const double PI = 3.14159265;
int n,x;
int tab[N];
int main(){
  clock_t start;
  cin >> n >> x;
  for(int i=0; i<n ; i++){
    cin >> tab[i];
  }
  sort(tab, tab+n);
  int ans=0,sum=0;
  for(int i=0; i<n; i++){
    if(i == n-1){
      if(tab[i] == x-sum) ans++;
    }
    else if(tab[i] <= x - sum){
      sum += tab[i];
      ans++;
    }
    else break;
  }
  cout << ans << endl;
  cerr << "Time: " << (clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " ms" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[200007];
char a[200007],b[200007];
int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    scanf("%s",s+1);
    for(int i=1;i<=q;i++){
        getchar();
        scanf("%c %c",&a[i],&b[i]);
    }
    int l=0,r=n+1;
    for(int i=q;i>=1;i--){
        if(b[i]=='L'){
            if(s[l+1]==a[i])
                l++;
            if(s[r]==a[i])
                r++;
        }
        else{
            if(s[r-1]==a[i])
                r--;
            if(s[l]==a[i])
                l--;
        }
    }
    int ans=r-l-1;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    cin >> H >> W;
    
    char area[H][W];
    int cloud[H][W];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> area[i][j];
            cloud[i][j]=-1;
        }
    }
    
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            for(int k=j; k>=0; k--){
                if(area[i][k] == 'c'){
                    cloud[i][j] = (j-k);
                    break;
                }
            }
        }
    }
    
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cout << cloud[i][j];
            if(j==W-1){
                cout << endl;
            }
            else cout << " ";
        }

    }
    return 0;
}



Measured memory_bytes: 3124
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

#define N 4
#define N2 16
#define LIMIT 1000

int MDT[N2][N2];
const int dx[4] { -1, 0, 1, 0 };
const int dy[4] { 0, -1, 0, 1 };
const char dir[4] { 'u', 'l', 'd', 'r' };

struct Puzzle {
	int f[N2], space, MD;
};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMd(Puzzle p) {
	int sum = 0;
	for (int i = 0; i < N2; ++i) {
		if (p.f[i] == N2)
			continue;
		sum += MDT[i][p.f[i] - 1];
	}
	return sum;
}

bool isSolved() {
	for (int i = 0; i < N2; ++i) {
		if (state.f[i] != i + 1)
			return false;
	}
	return true;
}

bool dfs(int depth, int prev) {

	if (state.MD == 0)
		return true;
	if (depth + state.MD > limit)
		return false;

	int sx = state.space / N;
	int sy = state.space % N;
	Puzzle tmp;

	for (int r = 0; r < 4; ++r) {
		int tx = sx + dx[r];
		int ty = sy + dy[r];
		if (tx < 0 || ty < 0 || tx >= N || ty >= N)
			continue;
		if (max(prev, r) - min(prev, r) == 2)
			continue;
		tmp = state;
		//????????????????????£?????????
		state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
		state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];

		swap(state.f[tx * N + ty], state.f[sx * N + sy]);
		state.space = tx * N + ty;

		if (dfs(depth + 1, r)) {
			path[depth] = r;
			return true;
		}
		state = tmp;
	}
	return false;
}

//??????
string iterate_deeping(Puzzle p) {

	p.MD = getAllMd(p);

	for (limit = p.MD; limit <= LIMIT; ++limit) {
		state = p;

		if (dfs(0, -100)) {
			string ans = "";
			for (int i = 0; i < limit; ++i) {
				ans += dir[path[i]];
			}
			return ans;
		}
	}
	return "";
}

int main() {

	for (int i = 0; i < N2; ++i) {
		for (int j = 0; j < N2; ++j) {
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
		}
	}
	Puzzle p;
	for (int i = 0; i < N2; ++i) {
		scanf("%d", &p.f[i]);
		if (p.f[i] == 0) {
			p.f[i] = N2;
			p.space = i;
		}
	}
	string ans = iterate_deeping(p);
	cout << ans.size() << endl;
	return 0;
}

Measured memory_bytes: 3272
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int a,b;
	cin>>a>>b;
	if(a%b){
		cout<<a/b+1;
	} 
	else{
		cout<<a/b;
	}
	re 0;
}

Measured memory_bytes: 256
import math

n = int(input())
arr = [0] * n

for x in range(1,700):
    for y in range(1,700):
        for z in range(1,701):
            ans = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if ans <= n:
                arr[ans - 1] += 1

for i in range(n):
    print(arr[i])

Measured memory_bytes: 74664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int sum = 0, a;
  rep(i, 4){
    scanf("%d", &a);
    sum += a;
  }
  printf("%d\n%d\n", sum/60, sum%60);
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(void){
  int x, y;
  string result;
  string x_check, y_check;
  cin >> x >> y;
  vector<int> A = {4,6,9,11};
  for(int i = 0; i < 4; i++){
    if(x == 2 || y == 2){
      cout << "No";
      x_check = "No";
      break;
    } else {
      if(x == A.at(i)){
        x_check = "A";
      }
      if(y == A.at(i)){
        y_check = "A";
      }
    }
  }
  if(x_check != "No" && x_check == y_check){
    cout << "Yes";
  } else if(x_check != "No"){
      cout << "No";
  }
}
        

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
	int d;
	int steps;
	int i;
	int ans=0;

	while(cin >> d){
		steps = 600 / d;
		ans = 0;
		for(i=0;i<steps;i++){
			ans += d * i * d * i * d;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

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

		int nx = stdIn.nextInt();
        int [] x = new int[nx];

        for(int i = 0; i < nx; i++){
        	x[i] = stdIn.nextInt();
        }
        stdIn.close();

        int count=0;
		for (int i = 0; i < nx - 1; i++) {
			int keyIndex = i;
            for (int j = i + 1; j < nx ; j++) {
                    if(x[keyIndex] > x[j]){
                    	keyIndex = j;
                    }
            }
            if(keyIndex == i) {
            	continue;
            }
            int tmp = x[i];
            x[i] = x[keyIndex];
            x[keyIndex] = tmp;
            count++;
        }
        out_put(x);
        System.out.println(count);
	}
	private static void out_put(int array[]){

        System.out.printf("%d", array[0]);

        if (array.length >1) {
        	for(int i = 1; i < array.length; i++){
        		System.out.printf(" %d", array[i]);
        	}
        }
        System.out.printf("%n");
    }
}



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

int main()
{
	int m,f,r;
	string s;
	while (1) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)
			break;
		else if (m == -1 || f == -1)
			s = "F";
		else if (m + f >= 80)
			s = "A";
		else if (m + f >= 65)
			s = "B";
		else if (m + f >= 50)
			s = "C";
		else if (m + f >= 30) {
			if (r >= 50)
				s = "C";
			else
				s = "D";
		}
		else
			s = "F";
		cout << s << endl;
	}
	return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(int i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<string,int> psi;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif

ll a,b,c,d;
cin>>a>>b>>c>>d;
ll ans=0,ans1=0,ans2=0,ans3=0,maxAB=0,maxCD=0,minAB=0,minCD=0;
maxAB=max(a,b);
maxCD=max(c,d);
minAB=min(a,b);
minCD=min(c,d);
ans = maxAB*maxCD;
ans1 = minAB*maxCD;
ans2 = minAB*minCD;
ans3 = maxAB*minCD;
cout<<max(ans,max(ans1,max(ans2,ans3)));
}



Measured memory_bytes: 3644
#include <stdio.h>

int main()
{
	int i=0,number;
	char blood[3];
	int A=0,B=0,O=0,AB=0;
	int ret;
	while(1){
		ret=scanf("%d,%s",&number,blood);
		if(ret==EOF){
			break;
		}
		else if(blood[1]=='B'){
			AB++;
		}
		else if(blood[0]=='A'){
			A++;
		}
		else if(blood[0]=='O'){
			O++;
		}
		else{
			B++;
		}
		i++;
	}
	printf("%d\n%d\n%d\n%d\n",A,B,AB,O);
	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <stdlib.h>

#define D_MAX 1000000000
#define N_MAX 100000
#define M_MAX 10000

int d;
int n;
int m;

int ad[N_MAX+1];
int ak[M_MAX+1];
int temp[N_MAX+1]; 

void MergeSort(int array[],int left,int right){
  int awork[N_MAX+1];
  int mid;
  int i;
  int j;
  int x;
  int y;
  
  if( left >= right ){
    return;
  }
  
  mid = (left + right) / 2;
  MergeSort( array, left, mid);
  MergeSort( array, mid+1, right);
  
  for( i=left; i<=mid; i++){
    awork[i] = array[i];
  }
  
  j = right;
  for( i=mid+1; i<=right; i++){
    awork[i] = array[j];
    j--;
  }
  
  x = left;
  y = right;
  
  for( i=left; i<=right; i++){
    if(awork[x] <= awork[y]){
      array[i] = awork[x];
      x++;
    }else{
      array[i] = awork[y];
      y--;
    }
  }
}


int calcDist(int k){
  int i;
  int diff;
  int preDiff = 0;
  int minDist = d;
  int tmpDist;
  int halfDist = d >> 1;
  
  for( i=0; i<=n; i++){
    diff = ad[i] - k;
    if( minDist > abs(diff) ){
      minDist = abs(diff);
    }
    preDiff = diff;
  }
  return minDist;
}

/*
int calcDist(int k){
	int i;
	int minDist = d;
	int tmpDist;
	int halfDist = d >> 1;
	
	for( i=1; i<=n; i++){
		tmpDist = abs(ad[i]-k);
		if( tmpDist > halfDist ){
			tmpDist = d-tmpDist;
		}
		if( minDist > tmpDist ){
			minDist = tmpDist;
		}
	}
	return minDist;
}
*/

void input(void){
  int i;
  scanf("%d",&d);
  if( d != 0){
    scanf("%d",&n);
    scanf("%d",&m);
    ad[0] = 0;
    for( i=1; i<=n-1; i++){
      scanf("%d",&ad[i]);
    }
    ad[n] = d;
    for( i=1; i<=m; i++){
      scanf("%d",&ak[i]);
    }
  }
}

int main(void){
  int i;
  int sumDist = 0;
  while( 1 ){
    input();
    if( d == 0 ){
      break;
    }
    MergeSort( ad, 0, n);
    for( i=1; i<=m; i++){
      sumDist += calcDist(ak[i]);
    }
    printf("%d\n",sumDist);
    sumDist = 0;
  }
}




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

using namespace std;


typedef long long ll;


int main()
{
    //freopen("", "r", stdin);freopen("", "w", stdout);
    int N, M, n, m;
    cin>>N>>M>>n>>m;
    cout<<N*M-n*M-m*N+n*m;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll; 
int main() {
  ll n, k;cin>>n>>k;
  ll cnt=0;
  rep(i, n) {
    ll h;cin>>h;
    if(h>=k) cnt++;
  }
  cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(auto i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? LONG_LONG_MAX : INT_MAX;
const int MOD = 1000000007;
const long double EPS = 1e-8;

signed main() {
	int n, m;
	cin >> n >> m;
	cout << abs(n - 2) * abs(m - 2) << endl;
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a + b == c + d) {
    cout << "Balanced" << endl;
  }
  
  else if (a + b <= c + d) {
    cout << "Right" << endl;
  }
  
  else if (a + b >= c + d) {
    cout << "Left" << endl;
  }
  
}

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

int main() {

    int D, T, S;
    cin >> D >> T >> S;

    if (D <= T*S) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3628