akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(int argc, char const *argv[]) {

    int cards[4][13] = {};

    int n;
    scanf("%d", &n);

    char suit;
    int num;

    for (int i = 0; i < n; i++) {
        scanf("%c", &suit);
        scanf("%c %d", &suit, &num);

        switch (suit) {
            case 'S':
                cards[0][--num] = 1;
                break;
            case 'H':
                cards[1][--num] = 1;
                break;
            case 'C':
                cards[2][--num] = 1;
                break;
            case 'D':
                cards[3][--num] = 1;
                break;
        }
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (cards[i][j] != 1) {
                switch (i) {
                    case 0:
                        printf("S %d\n", j+1);
                        break;
                    case 1:
                        printf("H %d\n", j+1);
                        break;
                    case 2:
                        printf("C %d\n", j+1);
                        break;
                    case 3:
                        printf("D %d\n", j+1);
                        break;
                }

            }
        }
    }

    return 0;
}


Measured memory_bytes: 2036
N = int(input())
A = list(map(int,input().split()))
A.sort()
final_list = []
plus = sum(x >= 0 for x in A)

def pop(length, flag):
  val = A[flag]
  A.pop(flag)
  for i in range(length):
    next_add = A[-1 - flag]
    final_list.append((val, next_add))
    val = val - next_add
    A.pop(-1 - flag)
  return val

if plus == N: #全部正の数
  ans = pop(N - 2, 0)
  final_list.append((max(ans, A[0]), min(ans, A[0])))
  ans = abs(ans - A[0])
elif plus == 0: #全部負の数
  ans = pop(N - 2, -1)
  final_list.append((max(ans, A[0]), min(ans, A[0])))
  ans = abs(ans - A[0])
else:
  ans_neg = pop(plus - 1, 0)
  ans_pos = pop(N - plus - 1, -1)
  final_list.append((ans_pos, ans_neg))
  ans = ans_pos - ans_neg
  


print(ans)
for i in range(len(final_list)):
  print(final_list[i][0], " ", final_list[i][1])

Measured memory_bytes: 19868
# -*- coding: utf-8 -*-
import math
H,W,D = map(int, input().split())

# Ah = np.array([0]*(H*W))
# Aw = np.array([0]*(H*W))
A = [0]*(H*W)
for h in range(H):
    As = list(map(int, input().split()))
    for w in range(W):
        A[As[w]-1] = (h,w)
    # Aw[As-1] = np.arange(W)
    # Ah[As-1] = h


Q = int(input())

# def solve(l, r):
#     ans = 0
#     # ah = Ah[l-1:r][::D]
#     # ans += np.sum(np.abs(ah[1:] - ah[0:-1]))
#     # aw = Aw[l-1:r][::D]
#     # ans += np.sum(np.abs(aw[1:] - aw[0:-1]))
#     ans = sum(Ah[l-1:l+D][::D])
#     while l != r:
#         x,y = A[l-1]
#         x2,y2 = A[l+D-1]
#         ans += abs(x-x2) + abs(y-y2)
#         l += D
#     return ans

Ans = [0]*(H*W)
aa = (H*W) // D
bb = (H*W) % D
for dth in range(1,aa+1):
    for d in range(D):
        if dth*D+d >=H*W:
            break
        x,y = A[(dth-1)*D+d]
        x2,y2 = A[dth*D+d]
        ans = abs(x-x2) + abs(y-y2)
        Ans[dth*D+d] = Ans[(dth-1)*D+d] + ans



lrs = []
for q in range(Q):
    L, R = map(int, input().split())
    print(Ans[R-1] - Ans[L-1])
    #lrs.append((L,R))

# for info in lrs:
#     L,R = info
#     print(solve(L, R))



Measured memory_bytes: 14260
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<(a-c)*(b-d)<<endl;
}

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

using ll = long long;

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

    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    
    N /= 2;
    ll ans = 0;

    for (ll i = 5; i <= N; i *= 5) {
        ans += N / i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    ll n; cin >> n;
    vector<ll> v(n);
    vector<ll> c(n);
    for(int i=0;i<n;i++){
        cin >> v.at(i);
    }
    for(int i=0;i<n;i++){
        cin >> c.at(i);
    }
    ll x=0, y=0, ans;
    for(int i=0;i<n;i++){
        if( v.at(i)>c.at(i) ){
            x += v.at(i);
            y += c.at(i);
        }
    }
    ans = x-y;
    cout << ans << endl;
}


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

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    for(int i = 0; i <N; i++) cin >> A[i];
    ll left[N], right[N]; // index iまでの和

    left[0] = A[0], right[N-1] = A[N-1];
    for(int i = 1; i < N; i++){
        left[i] = left[i-1] + A[i];
    }
    ll sum = left[N-1];
    ll ans = 1000000000000000000LL;
    for(int i = 0; i < N - 1; i++){
        ans = min(ans, abs(2 * left[i] - sum));
    }
    /*
    for(int i = N - 2; i >= 0; i--){
        right[i] = right[i+1] + A[i];
    }
    //for(int i = 0; i < N; i++) cout << right[i] << endl;
    ll minsum = 1e18;
    for(int i = 1; i < N; i++){
        minsum = min(minsum, llabs(left[i-1] - right[i]));
    }*/
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int cnt = 0;

    rep(i, n) {
        bool can = true;

        rep(j, i) {
            if (a[j] > a[i]) can = false;
        }
        if (can) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;

public class Main {
	private static final int K = 26;
	private static Random rand = new Random(System.currentTimeMillis());

	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var d = sc.nextInt();
		var c = new int[K];
		var s = new int[d][K];
		for (var i = 0; i < K; i++) {
			c[i] = sc.nextInt();
		}
		for (var i = 0; i < d; i++) {
			for (var j = 0; j < K; j++) {
				s[i][j] = sc.nextInt();
			}
		}
		sc.close();

		var t = create(c, s, d);
		var max = score(c, s, t, d);
		for (var i = 0; i < 8000; i++) {
			for (var j = 1; j < K; j++) {
				var index = i % d;
				var t2 = new int[d];
				for (var k = 0; k < d; k++) {
					t2[k] = t[k];
				}
				t2[index] = (t2[index] + j) % K + 1;
				var sum = score(c, s, t2, d);
				//System.out.println(sum);
				if (max < sum) {
					t = t2;
					max = sum;
				}
			}
		}

		for (var i = 0; i < d; i++) {
			System.out.println(t[i]);
		}
	}

	private static int score(int[] c, int[][] s, int[] t, int d) {
		var sum = 0;
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var ti = t[i] - 1;
			sum += s[i][ti];
			last[ti] = i + 1;
			for (var j = 0; j < K; j++) {
				sum -= ((i + 1) - last[j]) * c[j];
			}
		}

		return sum;
	}

	private static int[] create(int[] c, int[][] s, int d) {
		var t = new int[d];
		var last = new int[K];
		for (var i = 0; i < d; i++) {
			var v = new int[K];
			for (var j = 0; j < K; j++) {
				v[j] = s[i][j] + (((i + 1) - last[j]) * c[j]);
			}
			t[i] = rand(v) + 1;
			last[t[i] - 1] = i + 1;
		}
		return t;
	}

	private static int rand(int[] v) {
		var sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
		}
		var value = rand.nextInt(sum);
		var index = 0;
		sum = 0;
		for (var i = 0; i < v.length; i++) {
			sum += v[i];
			if (value < sum) {
				break;
			}
			index++;
		}
		//System.out.printf("%d %d %d\r\n", value, sum, index);
		return index;
	}
}


Measured memory_bytes: 56920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;

vector<ll> v(3);
ll n,k,m,x,y,a,b,c;
string s,t;
bool dp[101010];

int main() {
  int e=0;
  rep(i,3){
    cin >> v[i];
    if(!(v[i]&1)) e++; 
  }
  ll ans=0;
  if(e==0){
    sort(all(v));
    ans=v[0]*v[1]*(v[2]/2+1)-v[0]*v[1]*(v[2]/2);
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  
  int sum =0;
  int n = N;
  
  while(N > 0){
    sum += N % 10;
  
    N /= 10;
  }

  
  if(n % sum == 0)
    cout << "Yes"<< endl;
  else
    cout << "No"<< endl;
  
    
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n,k;
  cin>>n>>k;
  vector<long> a(n);
  rep(i,n) cin>>a[i];

  vector<long> v;
  rep(i,n){
    long acc = 0;
    rep(j,i,n){
      acc += a[j];
      v.pb(acc);
    }
  }

  long ans = 0;
  for(int i=42; i>=0; i--){dbg(v,ans);
    vector<long> nv;
    for(auto x : v){
      if((x>>i)%2 == 1){
        nv.pb(x);
      }
    }
    if(nv.size() >= k){
      swap(v, nv);
      ans += (1L<<i);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6388
#include <iostream>

using namespace std;

int t, m;
int ydir[9] = {0, 0, 0, 1, 1, 1, 2, 2, 2};
int xdir[9] = {0, 1, 2, 0, 1, 2, 0, 1, 2};

bool input(int a[3][3], bool used[11])
{
	fill(used, used+11, true);
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> a[i][j];
			used[a[i][j]] = false;
		}
	}
	cin >> m;
	used[m] = false;
	
	return !(m < 0);
}

bool comp(int a[3][3], int n)
{
	int r = (a[0][0]+a[0][1]+a[0][2])%n;
	
	if((a[1][0]+a[1][1]+a[1][2])%n == r &&
		 (a[2][0]+a[2][1]+a[2][2])%n == r &&
		 (a[0][0]+a[1][0]+a[2][0])%n == r &&
		 (a[0][1]+a[1][1]+a[2][1])%n == r &&
		 (a[0][2]+a[1][2]+a[2][2])%n == r &&
		 (a[0][0]+a[1][1]+a[2][2])%n == r &&
		 (a[0][2]+a[1][1]+a[2][0])%n == r){
			return true;
	}
	
	return false;
}

void func(int a[3][3], bool used[11], int n, int p)
{
	if(p == 9){
		if(comp(a, n)){
			t++;
		}
	} else {
		if(a[ydir[p]][xdir[p]] == 0){
			for(int i = 1; i < 11; i++){
				if(used[i]){
					used[i] = false;
					a[ydir[p]][xdir[p]] = i;
					func(a, used, n, p+1);
					a[ydir[p]][xdir[p]] = 0;
					used[i] = true;
				}
			}
		} else {
			func(a, used, n, p+1);
		}
	}
	
	return ;
}

int main()
{
	int a[3][3];
	bool used[11];
	
	while(input(a, used)){
		t = 0;
		if(m == 0){
			for(int i = 1; i < 11; i++){
				if(used[i]){
					used[i] = false;
					func(a, used, i, 0);
					used[i] = true;
				}
			}
		} else {
			func(a, used, m, 0);
		}
		
		cout << t << endl;
	}
	
	return 0;
}

Measured memory_bytes: 868
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int cnt=0;
		while(n!=1){
			if(n%2)n=n*3+1;
			else n/=2;
			cnt++;
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 1160
my $N = <STDIN>;
my $h,$n,$w;



foreach $h(1..3500){
foreach $n($h..3500){
	my $tmp;
	$tmp=4*$h*$n-$N*$h-$N*$n;
	next if ($tmp==0);
	next if($tmp<0);

	$w=($N*$h*$n)/$tmp;
#	if($w>0)
	{	
		next if($w != int ($w));

		print "$h $n $w\n";
		exit;
	}
}
}





Measured memory_bytes: 512
#include <iostream>

int main() {
    int a, b, c;
    std::cin >> a >> b >> c;
    int count_5 = 0;
    int count_7 = 0;
    switch (a) {
        case 5:
            ++count_5;
            break;
        case 7:
            ++count_7;
            break;
        default:
            break;
    }
    switch (b) {
        case 5:
            ++count_5;
            break;
        case 7:
            ++count_7;
            break;
        default:
            break;
    }
    switch (c) {
        case 5:
            ++count_5;
            break;
        case 7:
            ++count_7;
            break;
        default:
            break;
    }

    if (count_5 == 2 && count_7 == 1)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}


Measured memory_bytes: 3628
import sys

while True:
	num = int(input())
	if num == 0:
		break
	point = [0,0]
	for i in range(num):
		a, b = map(int, input().split())
		if a < b:
			point[1] += a+b
		elif b < a:
			point[0] += a+b
		else:
			point[0] += a
			point[1] += b

	print(point[0], point[1])


Measured memory_bytes: 5620
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

struct Job{
  int time;
  int limit;
  Job(int t,int l){
    time=t;
    limit=l;
  }
  bool operator>(const Job& another)const{
    return limit>another.limit;
  }
  bool operator<(const Job& another)const{
    return limit<another.limit;
  }
};

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  std::vector<Job> job;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    job.push_back(Job(a,b));
  }
  std::sort(job.begin(), job.end());
  int time=0;
  for(auto j:job){
    if(time>j.limit-j.time){
      cout<<"No"<<endl;
      return 0;
    }
    time+=j.time;
  }
  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 2420
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, K = rl()
MOD = 10 ** 9 + 7
A = np.array(rl())
B = np.array([])
answer = 0
add = 0
for a in A:
    answer += (B > a).sum()
    add += (A > a).sum()
    B = np.append(B, a)
answer *= K
answer %= MOD
time = (K-1) * K // 2 % MOD
answer += add * time
print(answer%MOD)
#50

Measured memory_bytes: 12384
n = int(input())
s = list(input())
l = []
count1 = 0
count2 = 0
for i in range(n):
    if s[i] == ")":
        if count2 == 0:
            l.append("(")
        else:
            count2 = count2 - 1
    else:
        count2 = count2 + 1
if count2 > 0:
    l2 = [")"]*count2
    ans = l + s + l2
    for i in ans:
        print(i, end = "")
else:
    ans = l + s
    for i in ans:
        print(i, end = "")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
  int n, sum = 0;
  cin >> n;
  int t[n];
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
    sum += t[i];
  }
  int m;
  cin >> m;
  int p[m], x[m];
  for (int i = 0; i < m; ++i) {
    int prev = sum;
    cin >> p[i] >> x[i];
    sum -= t[p[i] - 1];
    sum += x[i];
    cout << sum << '\n';
    sum = prev;
  }
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define int long long
#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

signed main() {
	int x;
	cin >> x;
	
	int ans = (x / 11) * 2 + ((x % 11) + 6 - 1) / 6;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int min = n+10;
    int ans = 0;
    for(int i=0; i<n; i++){
        if(min > p[i]){
            ans++;
            min = p[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
    queue<pair<string,int>>pq;
    //pq.push(make_pair("Promi",1));

    //pair<string, int> top = pq.front();
    //cout<<top.first<<" "<<top.second<<endl;
    int n,q;
    scanf("%d %d", &n,&q);
    int sum = 0;
    for(int i=0; i<n; i++)
    {
        getchar();
        string name;
        int time;
        cin>>name;
        cin>>time;
        pq.push(make_pair(name,time));
    }
    queue<pair<string,int>>pq1;

    while(!pq.empty())
    {
        if(pq.size()==1)
        {
            pair<string,int>top = pq.front();
            int number = top.second;
            string name = top.first;
            sum+=number;
            pq.pop();
            pq1.push(make_pair(name,sum));
        }
        else
        {
            pair<string,int>top = pq.front();
            int number = top.second;
            string name = top.first;
            if(number>q)
            {
                sum+=q;
                number = number - q;
                pq.pop();
                pq.push(make_pair(name,number));
            }
            else if(number<=q)
            {
                sum+=number;
                pq.pop();
                pq1.push(make_pair(name,sum));
            }
        }
    }
    while(!pq1.empty())
    {
        pair<string, int> top = pq1.front();
        cout<<top.first<<" "<<top.second<<endl;
        pq1.pop();
    }


}



Measured memory_bytes: 6364
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();

    let ans = *[a + b, a + a - 1, b + b - 1].iter().max().unwrap();

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
using namespace std;
const int A = 5000;
int a[A], b[A];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int an, bn;
	cin >> an >> bn;
	
	for(int i = 0; i < an; ++i)
		cin >> a[i];
	
	for(int i = 0; i < bn; ++i)
		cin >> b[i];
	
	int ans = 0;
	for(int i = 0; i < bn; ++i){
		for(int j = 0; j < an; ++j){
			if(b[i] == a[j]){
				int k = 1, m = 1;
				while(i + m < bn && j + k < an){
					if(b[i + m] == a[j + k])
						++m;
					++k;
				}
				ans = max(ans, m);
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<int> x(N),y(N);
    REP(i,N) cin>>x[i]>>y[i];
    vector<int> ord(N);
    iota(All(ord),0);
    double ans=0;
    do{
        double tmp=0;
        REP(i,N-1){
            tmp+=sqrt(pow(x[ord[i]]-x[ord[i+1]],2)+pow(y[ord[i]]-y[ord[i+1]],2));
        }
        ans+=tmp;
    }while(next_permutation(All(ord)));
    REP(i,N) ans/=i+1;
    printf("%.16f",ans);
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
   int i, j, n, S[100000], q, T[50000], key;
   int left, right, mid;
   int count = 0;
     
    scanf("%d",&n);
     
    for(i = 0; i < n; i++){
        scanf(" %d",&S[i]);
    }
    scanf("%d",&q);
     
    for(i = 0; i < q; i++){
        scanf(" %d",&T[i]);
    }
    
	for(key = 0; key < q; key++){
		left = 0;
		right = n;
		while (left < right){
			mid = (left + right) / 2;
			if (S[mid] == T[key]){ 
			count++;
			break;
			}else if(T[key] < S[mid]){
			right = mid;
			}else{
			left = mid + 1;
			}
		}
	}

	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 2304
#include<stdio.h>
int main(){
	int a,b,c;
	int d=0,cn=0;
	scanf("%d%d%d",&a,&b,&c);
	while(cn<c){
		cn=cn+a;
		d++;
		if(d%7==0)cn=cn+b;
	}
	printf("%d\n",d);
	return 0;
}


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

long long baseW;
long long N, W;
vector<long long> val[4];

long long getval(long long A, long long B, long long C, long long D){
	long long ret = 0;

	if(baseW * A + (baseW + 1) * B + (baseW + 2) * C + (baseW + 3) * D > W){
		return -1;
	}

	/*
	for(long long i = 0; i < A; i++){
		ret += val[0][i];
	}

	for(long long i = 0; i < B; i++){
		ret += val[1][i];
	}

	for(long long i = 0; i < C; i++){
		ret += val[2][i];
	}

	for(long long i = 0; i < D; i++){
		ret += val[3][i];
	}
	*/
	return val[0][A] + val[1][B] + val[2][C] + val[3][D];
	//return ret;
}

int main(){
	cin >> N >> W;
	for(long long i = 0; i < N; i++){
		long long tmpw, tmpv;
		cin >> tmpw >> tmpv;
		if(i == 0){
			baseW = tmpw;
		}
		val[tmpw - baseW].push_back(tmpv);
	}
	for(int i = 0; i < 4; i++){
		sort(val[i].begin(), val[i].end(), greater<long long>());
		val[i].insert(val[i].begin(), 0);
		for(int j = 0; j < val[i].size() - 1; j++){
			val[i][j+1] += val[i][j];
		}
	}

	long long ans = 0;
	for(long long i = 0; i < val[0].size(); i++){
		for(long long j = 0; j < val[1].size(); j++){
			for(long long k = 0; k < val[2].size(); k++){
				for(long long l = 0; l < val[3].size(); l++){
					ans = max(ans, getval(i, j, k, l));
				}
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int A[200005];
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<int,ll> m;
  for (int i=0; i<N; i++) {
    cin >> A[i];
    m[A[i]]++;
  }
  ll ret = 0;
  for (const auto& it : m) {
    ret += it.second * (it.second - 1) / 2;
  }
  for (int i=0; i<N; i++) {
    ll d = ret;
    ll t = m[A[i]];
    d -= t * (t - 1) / 2;
    d += (t - 1) * (t - 2) / 2;
    cout << d << '\n';
  }
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d;
  int house[5][4][11]={0};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b>>c>>d;
    house[a][b][c]+=d;
  }
  for(int h=1;h<=4;h++){
    for(int i=1;i<=3;i++){
      for(int j=1;j<=10;j++){
	cout<<" "<<house[h][i][j];
      }
      cout<<endl;
    }
    if(h!=4){
      cout<<"####################"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3100
import sys
import math

N = int(input())
# N, K = [int(i) for i in input().split()]
if N == 0:
    print(0)
    sys.exit(0)
if N % 2 == 1:
    print(0)
    sys.exit(0)

count = 0
digit = math.ceil(math.log(N, 5))
for i in range(1, digit+1):
    x = 5 ** i
    count += (N // (x * 2))
print(count)


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int n,cnt=1;
priority_queue<ll,vector<ll>,greater<ll> >q;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(ll i=1;i<=9;i++)
	{
		q.push(i);
	}
	while(cnt!=n)
	{
		cnt++;
		ll x=q.top();
		q.pop();
		if(x%10ll!=0ll)q.push(x*10ll+x%10ll-1ll);
		q.push(x*10ll+x%10ll);
		if(x%10ll!=9ll)q.push(x*10ll+x%10ll+1ll);
	}
	cout<<q.top();
	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

int main() {
    int n,k;
    cin >> n >> k;
    int ans = 0;
    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        if(a >= k){
            ans++;
        }
    }
    cout << ans << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int GCD(int n,int m)
{
	if(m==0)
		return n;
	return GCD(m,n%m);
}
int main()
{
	int a;
	scanf("%d",&a);
	printf("%d",2*a/GCD(2,a));
	return 0;
}

Measured memory_bytes: 256
#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>;
using Graph = vector<vector<int>>;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

    ll n, k, R, S, P;
    cin >> n >> k >> R >> S >> P;
	string t;
    cin >> t;
    ll total=0;
    rep(i,n){
        if(t[i]=='r'){
            total += P;
        }else if(t[i]=='s'){
            total += R;
        }else{
            total += S;
        }
    }
    for(int i=k; i<n; ++i){
        if(t[i]==t[i-k]){
            if(t[i]=='r'){
                total -= P;
                t[i]='x';
            }else if (t[i]=='s'){
                total -= R;
                t[i]='x';
            }else{
                total -= S;
                t[i]='x';
            }
        }
    }
    cout << total << "\n";
	return 0;
}

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

using namespace std;

int n;

int main() {
	scanf("%d",&n);
	bool flag=false;
	while (n>0) {
		if (n % 10==9) flag=true;
		n/=10;
	}
	if (flag) printf("Yes\n");
		else printf("No\n");
} 

Measured memory_bytes: 256
/**
 *  author: Behradm
 *  Created: 2020.08.02 15:47:05
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << (a >= 1 && a <= 9 && b >= 1 && b <= 9 ? a * b : -1) << '\n';
  return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>
#define meow(args...) fprintf(stderr, args)
const int N=2e5+5;
int n;
char s[N];
int main() {
	assert(scanf("%s", s)==1);
	n=strlen(s);
	int ans=0;
	for(int i=0, l=1; i<n; i+=l, l^=3, ++ans) {
		if(s[i]!=s[i-1]) l=1;
		if(i+l>n) break;
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

typedef pair< int, int > Pi;

int main()
{
  string S;
  int K;

  cin >> S;
  cin >> K;

  for(int i = 0; i < S.size(); i++) {
    int count = 'z' - S[i] + 1;
    if(S[i] != 'a' && K >= count) {
      S[i] = 'a';
      K -= count;
    }
  }

  S.back() = (S.back() - 'a' + K) % 26 + 'a';
  cout << S << endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

char map[100][100];
int h,w;
int d[5] = {1,0,-1,0,1};

int main(){
    cin >> h >> w;
    for(int i=0;i<h+2;i++) map[i][0]=map[i][w+1]='.';
    for(int i=0;i<w+2;i++) map[0][i]=0,map[h+1][i]='.';
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> map[i][j];
        }
    }
    bool f;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(map[i][j] == '.') continue;
            f = false;
            for(int k=0;k<4;k++){
                if(map[i+d[k]][j+d[k+1]]=='#'){
                    f = true;
                    break;
                }
            }
            if(!f){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define Rep(i,x) for(int i=head[x];i+1;i=nxt[i])
using namespace std;
const int N=200005;
typedef long long ll;
//------------------------------------------head---------------------------------------------------//
ll cnt[30];
char s[N];
int main()
{
	scanf("%s",s+1);ll n=strlen(s+1);
	ll ans=n*(n-1)/2ll+1ll;
	rep(i,1,n)cnt[s[i]-'a']++;
	rep(i,0,25)ans-=cnt[i]*(cnt[i]-1)/2ll;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			int m = in.nextInt();
			if(n+m==0)break;
			int[] taro = new int[n];
			int[] hana = new int[m];
			int tsum=0,hsum=0;
			for(int i=0;i<n;i++){
				taro[i]=in.nextInt();
				tsum+=taro[i];
			}
			for(int i=0;i<m;i++){
				hana[i]=in.nextInt();
				hsum+=hana[i];
			}
			int ans[] = {999,999};
			boolean sw = false;
			for(int i=0;i<n;i++){
				for(int s=0;s<m;s++){
					if(tsum-taro[i]+hana[s]==hsum-hana[s]+taro[i]&&taro[i]+hana[s]<ans[0]+ans[1]){
						ans[0]=taro[i];
						ans[1]=hana[s];
						sw=true;
					}
				}
			}
			if(sw==false)System.out.println("-1");
			else System.out.println(ans[0]+" "+ans[1]);
		}
	}
}

Measured memory_bytes: 21044
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n; cin >> n;
    vector<ll> a(n, 0);
    rep(i, n) {
        int x; cin >> x;
        a[x-1]++; 
    }
    sort(a.begin(), a.end());

    vector<ll> sum(n+1, 0);
    sum[0] = a[0];
    repr(i, 1, n) sum[i] = sum[i-1] + a[i];

    auto check = [&](ll x, ll k) {
        size_t i = upper_bound(a.begin(), a.end(), x) - a.begin();
        ll val = sum[i-1] + x*(n-i);
        return val >= k*x;
    };

    repr(k, 1, n+1) {
        ll ok = 0; ll ng = n/k+1;
        while(ng-ok > 1) {
            ll mid = (ok+ng) / 2;
            (check(mid, k)? ok:ng) = mid;
        }
        cout << ok << endl;
    }

    
    return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::sort;

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

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

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

  double value = vs[0];
  for (int i = 1; i < n; ++i) {
    value = (value + vs[i]) / 2;
  }

  cout << value << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int ketasum(ll n) {
    int ans = 0;
    while (true) {
        ans += n % 10;
        n /= 10;
        if (n == 0) {
            break;
        }
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    // double p[100001];
    // REP(i, 1, 100001) {
    //     ll num = ketasum(i);
    //     p[i] = (double)i / (double)num;
    // }
    // REP(i, 1, 100001) {
    //     bool ok = true;
    //     REP(j, i + 1, 100001) {
    //         if (p[i] > p[j]) {
    //             ok = false;
    //         }
    //     }
    //     if (ok) {
    //         cout << i << " ";
    //     }
    // }
    // cout << endl;
    vector<ll> vec;
    REP(i, 1, 1000) {
        ll tmp = i;
        REP(j, 0, 15) {
            vec.push_back(tmp);
            tmp = tmp * 10 + 9;
        }
    }
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    ll len = vec.size();
    vector<double> val(len);
    REP(i, 0, len) {
        ll keta = ketasum(vec[i]);
        val[i] = (double)(vec[i]) / (double)(keta);
    }
    vector<ll> ans;
    REP(i, 0, len) {
        bool ok = true;
        REP(j, i + 1, len) {
            if (val[i] > val[j]) {
                ok = false;
            }
        }
        if (ok) {
            ans.push_back(vec[i]);
        }
    }
    REP(i, 0, K) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {
		Scanner sc = new Scanner(System.in);
		int i = 0;
		List<String> klist = new ArrayList<String>();
		while (i < 1) {
			String line = sc.nextLine();
			klist.add(line);
			if (line.equals("0 0")) {
				break;
			}
		}
		
		for (String string : klist) {
			if (string.equals("0 0")) {
				break;
			}
			String[] k = string.split(" ");
			int v = Integer.parseInt(k[0]);
			int v2 = Integer.parseInt(k[1]);
			for (int j = 0; j < v; j++) {

				int count = 0;
				if (j == 0 || j == v - 1) {
					while (count < v2) {
						System.out.print("#");
						count++;
					}

				} else {
					System.out.print("#");
					count++;
					while (count < v2 - 1) {
						System.out.print(".");
						count++;
					}
					System.out.print("#");
				}
				System.out.println("");

			}
		
			System.out.println("");
		}
	}
}

Measured memory_bytes: 35108
#include <stdio.h>

#define INT_LEN 100

int StringLength(char *str)
{
    int length = 0;
    while (*str)
    {
        length++; 
        str++;
    }

    return length;
}

int main(void)
{
    char A[INT_LEN + 1];
    char B[INT_LEN + 1];
    if (scanf("%s\n%s", A, B) != 2)
    {
        puts("Input Error.");
        return 1;
    }

    int len_diff = StringLength(A) - StringLength(B);
    if (len_diff > 0)
        puts("GREATER");
    else if (len_diff < 0)
        puts("LESS");
    else
    {
        int equal = 1;
        for (int i = 0; i < StringLength(A); i++)
        {
            if (A[i] > B[i])
            {
                equal = 0;
                puts("GREATER");
                break;
            }
            else if (A[i] < B[i]) 
            {
                equal = 0;
                puts("LESS");
                break;
            }
        }
        if (equal) puts("EQUAL");
    }

    return 0;
}




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

string to_s(int n){
	string res;
	while(n){
		res += n%10+'0';
		n /= 10;
	}
	reverse(res.begin(),res.end());
	return res;
}
int main(){
	int N,W,c=1;
	int dp[2000];
	while(cin>>W&&W){
		fill(dp,dp+1001,0);
		cin>>N;
		while(N--){
			int v,w;
			cin>>v;
			cin.ignore();
			cin>>w;
			for(int i=W;0<=i;i--){
				dp[i+w] = max(dp[i+w],dp[i]+v);
			}
		}
		int *p = max_element(dp,dp+W+1);
		cout<<"Case "<<to_s(c++)<<':'<<endl;
		cout<<*p<<endl;
		cout<<p-dp<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <utility>
using namespace std;
#define P pair<string,int>

int main(){
  int n,m;
  P p[110];
  string s;

  while( cin>>n>>m && (n|m) ){
    for( int i=0;i<n;i++ )
      cin >> p[i].first >> p[i].second;

    int ans=0;
    for( int i=0;i<m;i++ ){
      cin >> s;

      for( int j=0,k;j<n;j++ ){

	for( k=0;k<8;k++ ){ // 1文字ずつチェック
	  if( p[j].first[k]=='*' )
	    continue;
	  if( p[j].first[k]!=s[k] )
	    break;
	}
	if( k==8 ){
	  ans += p[j].second;
	  break;
	}
      }

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

Measured memory_bytes: 928
S = input()
T = input()
min_diff = len(T)
for i in range(0,len(S)-len(T)+1):
    diff = 0
    for j in range(0,len(T)):
        if S[i+j] != T[j]:
            diff += 1
    else:
        min_diff = diff if min_diff > diff else min_diff
print(min_diff)

Measured memory_bytes: 8984
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n,i,c=0,x,c1=0;
	cin>>n;
	rep(i,n)
	{
		cin>>x;
		if(x%2==1)
			c++;
		if(x%4==0)
			c1++;
	}
	if(c<=c1)
	{
		cout<<"Yes"<<endl;
	}
	else if(c1+1==c&&c+c1==n)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
} 


Measured memory_bytes: 384
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)

typedef long long i64;
const int MAXN = 2000 + 10;

i64 answer;
i64 N, x;
i64 a[MAXN];
i64 min[MAXN], pos[MAXN];

int main()
{
	//REDIRECT("slime");

	scanf("%lld%lld", &N, &x);
	for(int i = 1; i <= N; i++)
		scanf("%lld", &a[i]), min[i] = a[i], pos[i] = i, answer += a[i];

	for(int i = 1; i <= N; i++)
	{
		i64 tans(0);
		for(int j = 1; j <= N; j++)
		{
			pos[j] --;
			if(pos[j] <= 0)
				pos[j] = N;

			min[j] = std::min(min[j], a[pos[j]]);
			tans += min[j];
		}
		answer = std::min(answer, tans + x * i);
	}


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

	CLOSEALL();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 110
#define infty 500000
#define whi 0
#define gry 1
#define bla 2
int prim();
int nk,abc[MAX][MAX];


int main(){
  int g;
  scanf("%d",&nk);
  for(int i=1;i<=nk;i++){
    for(int j=1;j<=nk;j++){
      scanf("%d",&g);
      if(g==-1){
	abc[i][j]=infty;
      }
      else{
	abc[i][j]=g;
      }
    }
  }
  printf("%d\n",prim());
  return 0;
}




int prim(){
  int uni,minvmin;
  int doctor[MAX],parent[MAX],cocoichi[MAX];

  for(int i=1;i<=nk;i++){
    doctor[i]=infty;
    parent[i]=-1;
    cocoichi[i]=whi;
  }

  doctor[1]=0;
  while(1){
    minvmin=infty;
    uni=-1;
    for(int i=1;i<=nk;i++){
      if(minvmin>doctor[i] && cocoichi[i] != bla){
	uni=i;
	minvmin=doctor[i];
      }
    }
    if(uni==-1)break;
    cocoichi[uni]=bla;
    for(int v=1;v<=nk;v++){
      if(cocoichi[v]!=bla && abc[uni][v]!=infty){
	if(doctor[v]>abc[uni][v]){
	  doctor[v]=abc[uni][v];
	  parent[v]=uni;
	  cocoichi[v]=gry;
	}
      }
    }
  }
  int sum=0;
  for(int i=1;i<=nk;i++){
    if(parent[i]!=-1){
      sum=sum+abc[i][parent[i]];
    }
  }
  return sum;
}






Measured memory_bytes: 1992
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <string>
#define int long long
#define P pair<int,int>
#define V vector<int>
#define rep(i,n) for(int i=0;i<n;++i)
#define vsort(vec) sort(vec.begin(),vec.end())
using namespace std;
signed main() {
	map<int, int> mp;
	int n, cnt = 0, ans = 0;
	cin >> n;
	++mp[0];
	rep(i, n) {
		int in;
		cin >> in;
		cnt += in;
		++mp[cnt];
	}
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		ans += it->second*(it->second - 1) / 2;
	}
	cout << ans << endl;
	system("PAUSE");
	return 0;
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define endl '\n'
using namespace std;
const int N = 1e5 + 5;

int n, m, a[N], label[N], base[N], temp[N];
ll k;
ll x[N], d[N], ans[N];

void by_p()
{
    for(int i = 1; i <= n; i++)
        temp[i] = label[base[i]];
    for(int i = 1; i <= n; i++)
        label[i] = temp[i];
}

void by_itself()
{
    for(int i = 1; i <= n; i++)
        temp[i] = label[label[i]];
    for(int i = 1; i <= n; i++)
        label[i] = temp[i];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> x[i];
        d[i] = x[i] - x[i - 1];
        label[i] = i;
        base[i] = i;
    }

    cin >> m >> k;
    for(int i = 1; i <= m; i++)
    {
        cin >> a[i];
        swap(base[a[i]], base[a[i] + 1]);
    }

    vector <int> b;
    while(k)
    {
        b.pb(k & 1);
        k /= 2;
    }
    reverse(b.begin(), b.end());
    for(int x: b)
    {
        by_itself();
        if(x)
            by_p();
    }

    for(int i = 1; i <= n; i++)
        ans[i] = d[label[i]];

    for(int i = 1; i <= n; i++)
        ans[i] = ans[i] + ans[i - 1];

    for(int i = 1; i <= n; i++)
        cout << ans[i] << endl;

    return 0;
}


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

int main(){
  int N; cin >> N;
  vector<int> nlis(N);
  int foo;

  for (int i = 0; i < N; i++){
    cin >> foo;
    nlis[N-foo] = i;
  }

  vector<int> bis = {-1,-1,N,N};
  long long ans = 0;
  vector<int>::iterator inser;
  long long a,b,c,d,e;

  for (int i = 0; i < N; i++){
    inser = lower_bound(bis.begin(),bis.end(),nlis[i]);
    c = nlis[i];
    b = *(--inser);
    a = *(--inser);
    ++inser;
    d = *(++inser);
    e = *(++inser);
    --inser;
    bis.insert(inser,nlis[i]);

    a = (e-d)*(c-b) +(d-c)*(b-a);

    ans += a*(N-i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1276
#include"stdio.h"
#include"cstdio"
#include"algorithm"
#include"string.h"
using namespace std;
const int max_n=1e2+10;
int A[max_n];
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		int i,p=0,q=0;
		for(i=0;i<n;i++)
		{
			scanf("%d",&A[i]);
			p+=A[i];
			q+=(A[i]*A[i]);
		}
		int d1,d2;
		if(p%n==0)
		d1=d2=p/n;
		else
		{
			d1=p/n;
			d2=p/n+1;
		}
		int sum1=n*d1*d1+q-2*p*d1;
		int sum2=n*d2*d2+q-2*p*d2;
		int sum=min(sum1,sum2);
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 128