akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ifor(a , b) for(int i = a ; i < b ; i++ )

using namespace std ;

int main()
{
  int n , m ; 
  scanf("%d%d" , &n , &m) ;
  cout << max(0 , n - 2*m ) ;
  return 0 ;
}

Measured memory_bytes: 256
class UnionFindTree:
    def __init__(self, size):
        self.parent = list(range(size))
        self.dist = [0] * size

    def find_root(self, x):
        if self.parent[x] == x:
            return x, 0
        else:
            self.parent[x], d = self.find_root(self.parent[x])
            self.dist[x] += d
            return self.parent[x], self.dist[x]

    def union(self, x, y, d):
        r1, d1 = self.find_root(x)
        r2, d2 = self.find_root(y)
        if r1 != r2:
            self.parent[r2] = r1
            self.dist[r2] = (d1 - d2) + d
        else:
            if (d2 - d1) != d:
                return False
        return True

def main():
    n, m = map(int, input().split())
    tree = UnionFindTree(n+1)
    for i in range(m):
        l, r, d = map(int, input().split())
        if not tree.union(l, r, d):
            print('No')
            return
    print('Yes')

main()

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  auto judge = [](string s) {
    int n = sz(s);
    if (n % 2 == 1) return false;
    rep(i, n / 2) {
      if (s[i] != s[i + n / 2]) return false;
    }
    return true;
  };
  string s;
  cin >> s;
  rrep(r, sz(s)) {
    if (judge(s.substr(0, r))) {
      cout << s.substr(0, r).size() << endl;
      return;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
s=list(input())
odd=['R','U','D']
even=['L','U','D']

for i in range(len(s)):
    if (i+1)%2:
        if s[i] not in odd:
            print('No')
            exit()
    else:
        if s[i] not in even:
            print('No')
            exit()
print('Yes')

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

int main() {

    int N;

    cin >> N;

    int x;
    x = N/1000;
    double y;
    y = N/1000.;

    if (y > x) {
        int change = 1000*(x+1) - N;
        cout << change << endl;
    }
    else {
        int change = 1000*x - N;
        cout << change << endl;
    }
}

Measured memory_bytes: 3624
n = int(input())
st = [list(input().split()) for i in range(n)]
x = input()

k = 0
for i in range(n):
    s, t = st[i]
    if s == x:
        k = i
ans = 0
for i in range(k + 1, n):
    s, t = st[i]
    ans += int(t)

print(ans)


Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

if sum(a) < sum(b):
    print(-1)
    exit()

ans = 0
memo = []
tmp = 0

for i in range(n):
    if a[i] >= b[i]:
        memo.append(a[i]-b[i])
    else:
        tmp += b[i]-a[i]
        ans += 1

memo.sort(reverse = True)

if len(memo) != len(a):
    for j in memo:
        if j < tmp:
            tmp -= j
            ans += 1
        else:
            ans += 1
            break

print(ans)

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

int A[100];


void trace( int[], int N){
	for(int i=0; i<N; i++){
		if( i>0 ) cout << " ";
		cout << A[i];
	}
	cout << "\n";
}


void Sort( int[], int N){
	int j,v;
	for(int i=1; i<N; i++){
		v = A[i];
		j = i-1;
		while( j>=0 && A[j]>v ){
			A[j+1] = A[j];
			j--;
		}

		A[j+1] = v;
		trace(A,N);
	}
}


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

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

	trace(A,N);
	Sort(A,N);

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  vector<string> A={"SS","SW","WS","WW"};
  for(int j=0;j<4;j++){
    string T=A[j];
    for(int i=2;i<N;i++){
      if(T[i-1]=='S' && S[i-1]=='o')T+=T[i-2];
      else if(T[i-1]=='S')T+='S'+'W'-T[i-2];
      else if(S[i-1]=='o')T+='S'+'W'-T[i-2];
      else T+=T[i-2];
    }
    if(((T[N-1]=='S' && S[N-1]=='o') || (T[N-1]=='W' && S[N-1]=='x'))){
      if(T[N-2]!=T[0])continue;
    }else if(T[N-2]==T[0])continue;
    if(((T[0]=='S' && S[0]=='o') || (T[0]=='W' && S[0]=='x'))){
      if(T[N-1]!=T[1])continue;
    }else if(T[N-1]==T[1])continue;
    cout<<T<<endl;
    return 0;
  }
  puts("-1");
}

Measured memory_bytes: 3932
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

int t = 0, m;
vector<int> G;


void insertionSort(vector<int> &a, int n, int g) {
  int v, j;
  FOR(i, g, n) {
    v = a[i];
    j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j -= g;
      t++;
    }
    a[j + g] = v;
  }
}

void shellSort(vector<int> &a, int n) {
  m = G.size();
  reverse(G.begin(), G.end());
  cout << m << endl;
  rep(i, m) {
    if (i) cout << " ";
    cout << G[i];
    insertionSort(a, n, G[i]);
  }
  cout << endl;
  cout << t << endl;
  rep(i, n) {
    cout << a[i] << endl;
  }
}


int main() {
  int n, gc = 1;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  while (gc <= n) {
    G.push_back(gc);
    gc = gc * 3 + 1;
  }

  shellSort(a, n);
  

  
  return 0;
}


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

using namespace std;

namespace old {
	int h(int a, int b) {
		if (a + b <= 1) return a + b;
		if (min(a, b) == 0) return a + b;
		return max((a + b) / (b + 1), (a + b - 1) / a);
	}

	int f(int a, int b, int res) {
		return min(min(a, res), a + 1 - (b + res - 1) / res);
	}

	int g(int a, int b, int res) {
		return max(1ll, a - b * 1ll * res - 1);
	}

	void main(int a, int b, int c, int d) {
		vector<pair<char, int>> vec;
		
		int res = min(h(a, b), h(b, a));
		if (h(a, b) == res) {
			int x = f(a, b, res);
			vec.emplace_back('A', x);
			a -= x;
		}
		else {
			int y = g(a, b, res);
			vec.emplace_back('B', y);
			b -= y;
		}
		
		while (a + b > 0) {
			if (vec.back().first == 'A') {
				int y = g(a, b, res);
				vec.emplace_back('B', y);
				b -= y;
			}
			else {
				int x = f(a, b, res);
				vec.emplace_back('A', x);
				a -= x;
			}
		}
		
		size_t i = 0;
		while (vec[i].second < c) {
			c -= vec[i].second;
			d -= vec[i].second;
			i++;
		}
		
		while (d > 0) {
			for (int j = max(c, 1); j <= min(vec[i].second, d); j++) printf("%c", vec[i].first);
			c -= vec[i].second;
			d -= vec[i].second;
			i++;
		}
		
		printf("\n");
	}
}

int h(int a, int b) {
	if (a + b <= 1) return a + b;
	if (min(a, b) == 0) return a + b;
	return max((a + b) / (b + 1), (a + b - 1) / a);
}

int f(int a, int b, int res) {
	if (b == 0) return a;
	return min(res, a + 1 - (b + res - 1) / res);
}

int g(int a, int b, int res) {
	return max(1ll, b - a * 1ll * res);
}

int main() {
	int T;
	ignore = scanf("%d", &T);
	while (T--) {
		int a, b, c, d;
		ignore = scanf("%d %d %d %d", &a, &b, &c, &d);
		
		if (a + b < 2000) {
			old::main(a, b, c, d);
			continue;
		}
		
		int res = min(h(a, b), h(b, a));
		bool lastA = h(a, b) > res;
		
		while (a + b > 0) {
			//printf("(%d, %d)", a, b);
			
			if (lastA) {
				int y = g(a, b, res);
				
				int k = 0;
				for (int i = (1 << 29); i > 0; i >>= 1)
					if (k + i <= a && y * 1ll * (k + i) <= b && h(b - y * (k + i), a - k - i) <= res)
						k += i;
				
				//printf("{%d, %d}", y, k);
				
				if (k == 0) {
					b -= y;
					
					c -= y;
					d -= y;
					while (c <= d && c < 1) {
						printf("B");
						c++;
					}
					
					lastA = false;
				}
				
				a -= k;
				b -= k * y;
				
				int it = c;
				c -= (y + 1) * k;
				d -= (y + 1) * k;
				while (c <= d && c < 1) {
					printf(it % (y + 1) == 0 ? "A" : "B");
					it++;
					c++;
				}
			}
			else {
				int x = f(a, b, res);
				
				int k = 0;
				for (int i = (1 << 29); i > 0; i >>= 1)
					if (k + i <= b && x * 1ll * (k + i) <= a && h(a - x * (k + i), b - k - i) <= res)
						k += i;
				
				//printf("[%d, %d]", x, k);
				
				if (k == 0) {
					a -= x;
					
					c -= x;
					d -= x;
					while (c <= d && c < 1) {
						printf("A");
						c++;
					}
					
					lastA = true;
				}
				
				a -= k * x;
				b -= k;
				
				int it = c;
				c -= (x + 1) * k;
				d -= (x + 1) * k;
				while (c <= d && c < 1) {
					printf(it % (x + 1) == 0 ? "B" : "A");
					it++;
					c++;
				}
			}
		}
		
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

  cin >> n;

  int o = 1;
  int a;

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

  cout << (o == 1 ? -1 : n - o + 1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
#define N 100010
using namespace std;
int dp[N], A[N], n, k;
int fun(int a){
	if(a >= n)
		return 1e9;
	if(a == n - 1){
		return 0;
	}
	if(dp[a] != -1)
		return dp[a];
	int mini = 2 * 1e9;
	for(int i = 1; i <= k; i++){
		mini = min(mini, abs(A[a] - A[a + i]) + fun(a + i));
	}
	return dp[a] = mini;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> A[i];
	memset(dp, -1, sizeof(dp));
	cout << fun(0) << '\n';

}

Measured memory_bytes: 5760
n, m = [int(i) for i in input().split(" ")]
H = [int(i) for i in input().split(" ")]
ans = [1] * n
for i in range(m):
    a, b = [int(i) for i in input().split(" ")]
    if H[a - 1] <= H[b - 1]:
        ans[a - 1] = 0
    if H[a - 1] >= H[b - 1]:
        ans[b - 1] = 0
print(sum(ans))


Measured memory_bytes: 20112
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{

	int x1, x2, y1, y2, x3, y3, x4, y4;
	cin >> x1 >> y1 >> x2 >> y2;

	if (x2 - x1 > 0 && y2 - y1 >= 0) {
		cout << x2 - (y2 - y1) << " " << y2 + (x2 - x1) << " " << x1 - (y2 - y1) << " " << y1 + (x2 - x1);
	}
	else if (x2 - x1 <= 0 && y2 - y1 > 0) {
		cout << x2 - (y2 - y1) << " " << y2 + (x2 - x1) << " " << x1 - (y2 - y1) << " " << y1 + (x2 - x1);
	}
	else if (x2 - x1 < 0 && y2 - y1 >= 0) {
		cout << x2 - (y2 - y1) << " " << y2 + (x2 - x1) << " " << x1 - (y2 - y1) << " " << y1 + (x2 - x1);
	}
	else {
		cout << x2 - (y2 - y1) << " " << y2 + (x2 - x1) << " " << x1 - (y2 - y1) << " " << y1 + (x2 - x1);
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    int h, w; cin >> h >> w;
    map<int,int> x, y;
    char a[w][h];

    rep(i,h) rep(j,w) cin >> a[j][i];

    rep(i,h) rep(j,w) if(a[j][i] == '#') break; else if(j == w-1) y[i]++;
    rep(i,w) rep(j,h) if(a[i][j] == '#') break; else if(j == h-1) x[i]++;

    rep(i,h){
        rep(j,w) if(x[j] == 0 && y[i] == 0) cout << a[j][i];
        if(y[i] == 0) cout << endl;
    }
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

# -- Union Find
par = [i for i in range(N)]
rank = [0]*N

def root(x):
    if par[x] != x:
        par[x] = root(par[x])
    return par[x]

def same(x, y):
    return root(x) == root(y)

def unite(x, y):
    x, y = root(x), root(y)
    if x == y: return

    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

# -- Union Find


block_num = [0]*N
friend_num = [0]*N
cls_cnt = {} # cluster count

for ab in AB:
    a, b = ab[0]-1, ab[1]-1
    unite(a,b)


for ab in AB:
    a, b = ab[0]-1, ab[1]-1
    if same(a,b):
        friend_num[a] += 1
        friend_num[b] += 1


for cd in CD:
    c, d = cd[0]-1, cd[1]-1
    if same(c,d):
        block_num[c] += 1
        block_num[d] += 1


cls_cnt = {} # cluster count
for i in range(N):
    r = root(i)
    if r in cls_cnt:
        cls_cnt[r] += 1
    else:
        cls_cnt[r] = 1


for i in range(N):
    r = root(i)
    ans = cls_cnt[r] - 1 - friend_num[i] - block_num[i]
    print(ans , end=' ')


Measured memory_bytes: 67488
#include<stdio.h>
#include<string.h>

int main() {
    int number, time[50], sleep_num, S;
    int i, sum = 0;
    char name[5000][1000], sleep[1000];

    scanf("%d", &number);

    for(i = 0;i < number;i++) {
        scanf("%s %d", name[i], &time[i]);
    }

    scanf("%s", sleep);

    S = strlen(sleep);

    for(i = 0;i < number;i++) {
        if(strlen(name[i]) == strlen(sleep))
        if(strcmp(sleep, name[i]) == 0) {
            sleep_num = i;
        }
    }

    for(i = sleep_num + 1;i < number;i++) {
        sum = sum + time[i];
    }

    printf("%d", sum);

    return 0;

}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

Measured memory_bytes: 764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <utility>
#include <vector>

#define MAX_LEN (100L)
#define MAX_K (1000000000L)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  char c, cs[MAX_LEN + 2];
  long K;
  fgets(cs, MAX_LEN + 2, stdin);
  scanf("%ld", &K);
  const long len = strlen(cs) - 1;
  cs[len] = '\0';
  // printf("%s\n", cs);
  // printf("%ld\n", K);

  // group
  vector<pair<char, long>> consecutive_char_counts;
  long count = 1;
  for (long i = 1; i < len; i++) {
    if (cs[i] != cs[i - 1]) {
      consecutive_char_counts.push_back(make_pair(cs[i - 1], count));
      count = 1;
    } else {
      count++;
    }
  }
  consecutive_char_counts.push_back(make_pair(cs[len - 1], count));
  // for (pair<char, long> char_count : consecutive_char_counts) {
  //   printf("%c: %ld\n", char_count.first, char_count.second);
  // }

  // solve
  const long num_groups = consecutive_char_counts.size();
  long ans = 0;
  if (num_groups == 1) {
    ans = consecutive_char_counts[0].second * K / 2;
  } else {
    for (long i = 1; i < num_groups - 1; i++) {
      ans += consecutive_char_counts[i].second / 2 * K;
    }
    const char c_first = consecutive_char_counts[0].first,
               c_last = consecutive_char_counts[num_groups - 1].first;
    const long count_first = consecutive_char_counts[0].second,
               count_last = consecutive_char_counts[num_groups - 1].second;
    if (c_first == c_last) {
      ans += count_first / 2;
      ans += count_last / 2;
      ans += (count_first + count_last) / 2 * (K - 1);
    } else {
      ans += count_first / 2 * K;
      ans += count_last / 2 * K;
    }
  }
  printf("%ld\n", ans);

  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

int gcd(int x, int y){
	return y ? gcd(y, x%y) : x;
}

void Main(){
	int k;
	cin >> k;
  	ll ans = 0;
	rep3(a,1,k) {
		rep3(b,1,k){
			int temp = gcd(a,b);
        	rep3(c,1,k){
            	ans += gcd(temp,c);
            }
        }
    } 
    cout << ans << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

ll dp[n][n]{};

int main() {
    int N, M;
    cin >> N >> M;
    ll D[N], C[M];
    
    for (int i = 0; i < N; i++) {
        cin >> D[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> C[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dp[i][j] = 1000000000000;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        ll v = 1000000000000;
        for (int j = i; j <= M - N + i; j++) {
            v = min(v, dp[i][j]);
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], v + D[i] * C[j]);
        }
    }
    ll ans = dp[N][M];
    for (int i = N; i < M; i++) {
        ans = min(ans, dp[N][i]);
    }
    cout << ans << "\n";
    return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int N;
  cin >> N;
  vector<int> b(N);
  REP(i, N){
    cin >> b[i];
    b[i]--;
  }
  vector<int> ans;
  REP(i, N){
    REPR(j, b.size()-1){
      if(b[j] == j){
        ans.push_back(j+1);
        b.erase(b.begin()+j, b.begin()+j+1);
        break;
      }
    }
    if(b.size() != N-i-1){
      // cout << "i" << i << " b.size(): " << int(b.size()) << endl;
      cout << "-1" << endl;
      return 0;
    }
  }
  REPR(i, N-1){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int count = 0;
        //String str = sc.next();
        //char[] c = str.toCharArray();
        //a[0] = Character.getNumericValue(str.charAt(0));
        //boolean test = false;
        
        for(int i=0; i<=K; i++){
            for(int j=0; j<=K; j++){
                if((S-i-j) >= 0 && (S-i-j) <= K){
                    count++;
                }
            }
            //System.out.println(a[i]);
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35704
s = input()
K = int(input())
base_count = ord("z") + 1
ans = ""
for c in s:
    t = (base_count - ord(c)) % 26
    if t <= K:
        ans += "a"
        K -= t
    else:
        ans += c
if K > 0:
    K = K % 26
    ans = ans[:-1] + chr((ord(ans[-1]) + K))
print(ans)

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

from collections import Counter
c = Counter(A)

x = 0
y = 0
for k, v in sorted(c.items(), key=lambda x: -x[0]):
    if v >= 4 and x == 0 and y == 0:
        x = y = k
    elif v >= 2:
        if x == 0:
            x = k
        elif y == 0:
            y = k

print(x*y)

Measured memory_bytes: 72344
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;

void solve(){
  long long x, a = 100, i; cin >> x;
  for(i = 0; a < x; i++){
    a = a * 1.01;
    //cout << a << endl;
  }
  cout << i << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3636
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n,x;
signed main(){
    I(n); I(x);
    if (x == 1 || x == 2*n-1){
        printf("No\n");
    } else {
        printf("Yes\n");
        int seq = 0;
        REP(i,n-2){
            seq++;
            while(abs(seq-x) <= 1) seq++;
            printf("%lld\n", seq);
        }
        printf("%lld\n%lld\n%lld\n", x-1,x,x+1);
        REP(i,n-2){
            seq++;
            while(abs(seq-x) <= 1) seq++;
            printf("%lld\n", seq);
        }
    }
}

Measured memory_bytes: 1536
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	string s,t,u;
	cin >> s >> t >> u;
	cout << "A" + t.substr(0, 1) + "C" << endl;
	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;

signed main() {
  int n, k; cin >> n >> k;
  vector<ll> v(n); rep(i, n) cin >> v[i];

  ll ans = 1e9;
  rep(i, n-k+1) {
    ans = min(ans, v[i+k-1] - v[i] + min(abs(v[i]), abs(v[i+k-1])));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int n, k;
    cin>>n>>k;
    ll ans = 0ll;
    ans += pow(n / k, 3);
    if (k % 2 == 0)
        ans += pow(n / (k / 2) - n / k, 3);

    cout<<ans<<endl;

    return 0;
}


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

using namespace std;
const int mod=1e9+7;
int add_self(int &a,int b)
{
    a+=b;
    if(a>=mod)
    {
        a-=mod;
    }
}

int main()
{
    int n=0;
    scanf("%d",&n);
    vector<vector<int>>can(n,vector<int>(n));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            scanf("%d",&can[i][j]);
        }
    }
    vector<int>dp(1<<n);
    dp[0]=1;
    for(int mask=0;mask<(1<<n)-1;mask++)
    {
        int a=__builtin_popcount(mask);
        for(int b=0;b<n;b++)
        {
            if(can[a][b]&&!(mask & (1<<b)))
            {
                int m2=mask ^ (1<<b);
                add_self(dp[m2],dp[mask]);
            }
        }
    }
    printf("%d\n",dp[(1<<n)-1]);
}



Measured memory_bytes: 8576
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
using namespace std;

int main(){
    int n, x, y;
    cin>>n;
    x=800*n;
    y=(n/15)*200;
    cout<<x-y<<endl;
}


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

int main(){

    int h = 202020;
    int t = -1;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A')h = min(h, i);
        if(s[i] == 'Z')t = max(t, i);
    }
    cout << t - h + 1 << endl;


    return 0;
}

Measured memory_bytes: 640
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
using namespace std;
#define int long long
struct edge{int to, cap, rev;};
vector< vector<edge> > G(102);
int level[102];
int iter[102];
const int INF = 1e15;

void bfs(int s){
  memset(level, -1, sizeof(level));
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(int i = 0; i < G[v].size(); ++i){
      edge &e = G[v][i];
      if(e.cap > 0 && level[e.to] < 0){
        level[e.to] = level[v] + 1;
        que.push(e.to);
      }
    }
  }
}

int dfs(int v, int t, int f){
  if(v == t) return f;
  for(int &i = iter[v]; i < G[v].size(); ++i){
    edge &e = G[v][i];
    if(e.cap > 0 && level[v] < level[e.to]){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t){
  int flow = 0;
  for(;;){
    bfs(s);
    if(level[t] < 0) return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f = dfs(s,t,INF)) > 0){
      flow += f;
    }
  }
}

signed main(){
  int N;
  cin >> N;
  int ans = 0LL;
  for(int i = 1; i <= N; ++i){
    int a;
    cin >> a;
    if(a > 0){
      ans += a;
      G[i].push_back((edge){N+1,a,G[N+1].size()});
      G[N+1].push_back((edge){i,0,G[i].size()-1});
    }else{
      G[0].push_back((edge){i,-a,G[i].size()});
      G[i].push_back((edge){0,0,G[0].size()-1});
    }
  }
  for(int i = 1; i <= N; ++i){
    for(int j = 2; i*j <= N; ++j){
      G[i].push_back((edge){i*j,INF,G[i*j].size()});
      G[i*j].push_back((edge){i,0,G[i].size()-1});
    }
  }
  cout << ans - max_flow(0,N+1) << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a=scan.next();
		String b=scan.next();
if(a.equals("H")) {
	if(b.equals("H")) {
		System.out.println("H");
	}
	else {
		System.out.println("D");
	}
		}
if(a.equals("D")) {
	if(b.equals("H")) {
		System.out.println("D");
	}
	else {
		System.out.println("H");
	}
}
		}
}

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

int main() {
  string s;
  int count = 0;
  cin >> s;
  rep(i, s.size() / 2) {
    if (s[i] != s[s.size() - 1 - i]) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(a) int((a).size())
#define fr(i,n) for(int i=0;i<n;i++) 
#define rf(i,n) for(int i=1;i<=n;i++) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define MAX INT_MAX 
#define f first
#define s second
using namespace std;
#define M 1000000007
int main()
{
    int n,k;
    cin>>n>>k;
    std::vector<int> v(n);
    fr(i,n)
    cin>>v[i];
    int dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++)
    {
        int mi = INT_MAX;
        for(int j=i-1;j>=max(0,i-k);j--)
            mi = min(mi,abs(v[i]-v[j])+dp[j]);
        dp[i]=mi;
    }  
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 4052
import Control.Monad
solve :: Int -> [Int] -> Int
solve c [a,b] = if (((a * a) + (b * b)) <= (c * c)) then 1 else 0

main = do
 [n,d] <- map read . words <$> getLine :: IO [Int]
 ans <- replicateM n $ (solve d) . (map read . words) <$> getLine
 print $ sum ans

Measured memory_bytes: 165528
n, a, b = map(int,input().split())

sum = 0
if a == 0:
  print(0)
elif n <= a:
  print(n)
elif int(n / (a + b)) == 0:
  print(a)
else:
  nn = int(n / (a + b))
  na = n % (a + b)
  sum = nn * a + min(na,a) 
  print(sum)

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    double r;
    cin >> r;
    printf("%.10f\n", 2 * M_PI * r);

    return 0;
}

Measured memory_bytes: 3804
#include <stdio.h>
#include <string.h>

typedef struct{
  char name[100];
  int t;
}Queue;
 
Queue Q[100000];
int i, head = 0, tail = 0;
 
void enqueue(Queue);
Queue dequeue(void);  
 
int main(){
  int p, q, count = 0, time = 0;
  Queue cell;
   
  scanf("%d %d",&i,&q);
   
  for (p = 1; p <= i; p++){
    scanf("%s",Q[p].name);
    scanf("%d",&Q[p].t);
  }
  
    // printf("\n");

  
  while(count != i){
    cell = dequeue();
    if(cell.t - q <= 0){
      time += cell.t;
      cell.t = 0;
      count++;

 
      printf("%s %d",cell.name ,time);
      printf("\n");   
       
    } else if (cell.t > 0){
      time += q;    
      cell.t -= q;
      enqueue(cell);
    }
     
  }
   
  return 0;
  
}
   
 
void enqueue(Queue x){ 
 
  if(tail == i)   tail = 1;
   else {
    tail++;
  }
   
  Q[tail] = x;
}
   
 
Queue dequeue(){
  if(head == i)   head = 1;
   
  else {
    head++;
  }
  return Q[head];
}

Measured memory_bytes: 6748
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}



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

    ll ans = TEN(18);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            b[j] = min(b[j], a[(j-i+n)%n]);
        }
        ll buf = x*i;
        for (int j = 0; j < n; j++) {
            buf += b[j];
        }
        ans = min(ans, buf);
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){

    char S[16];

    scanf("%s", S);

    int len = strlen(S);

    long long sum = 0;

    for(int i = 0; i < (int)pow(2, len-1); i++){
        long long k = 1;
        sum += S[len-1] - 48;

        for(int j = 0; j < len-1; j++){
            if((i>>j)&1){
                k *= 10;
            }else{
                k = 1;
            }
            sum += (S[len-2-j] - 48) * k;
        }
    }

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

    return 0;
}

Measured memory_bytes: 2504
#include <stdio.h>

int main(void){

	int a,b,c,x;

	scanf("%d %d %d",&a,&b,&c);

	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	if(b>c){
		x=b;
		b=c;
		c=x;
	}
	if(a>b){
		x=a;
		a=b;
		b=x;
	}

printf("%d %d %d\n",a,b,c);

	return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
L=list(map(int,input().split()))
A = L.count(1)
B = L.count(2)
C = L.count(3)
dp=[[[0.0] * (n+1) for i in range(n+1)] for i in range(n+1)]

for c in range(C+1):
  for b in range(B+C+1-c):
    for a in range(A+B+C+1-c-b):
      if a == b == c == 0:continue
      result = n
      result += (dp[a-1][b][c]*a if a-1 >= 0 else 0)
      result += (dp[a+1][b-1][c]*b if b-1 >= 0 else 0)
      result += (dp[a][b+1][c-1]*c if c-1 >= 0 else 0)
      dp[a][b][c]=result / (a+b+c)

print(dp[A][B][C])

# def rec (a,b,c):
  # if not (a >= 0 and b >= 0 and c >= 0):
  #   return 0
  # if a == b == c == 0:
  #   return 0
  # if dp[a][b][c] != -1:
  #   return dp[a][b][c]
  # result = n
  # result += rec(a-1,b,c) * a
  # result += rec(a+1,b-1,c) * b
  # result += rec(a,b+1,c-1) * c
  # dp[a][b][c] = result / (a+b+c)
  # return dp[a][b][c]


Measured memory_bytes: 253960
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 30/12/2017 15:24:51
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	int m;
	cin>>m;
	cout<<48-m<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S = str(input())
N = len(S)-1

N1 = int((N-1)/2)
N2 = int((N+3)/2)

s1 = S[:N]
s2 = S[:N1]
s3 = S[N2-1:N]

flag = True
for ss in [s1, s2, s3]:
    ss_l = len(ss)
    for i in range(ss_l):
        if ss[i] != ss[ss_l-i-1]:
            flag = False
            break
    if not flag:
        break

if flag:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

const int maxn=200000;
const int maxv=99999999;
const double D=11.4159265358979323846264338328;
const double K=-4.2920367320510338076867830836;

int n,m,maxy,sx,sy,tx,ty,tot,c[maxn+10],pos[maxn+10],cnt;
double ans;

struct point
{
  int x,y;
  
  bool ft()
  {
    return x>=sx&&x<=tx&&y>=sy&&y<=ty;
  }
  
  bool operator <(const point &other) const
  {
    return x<other.x;
  }
};

point p[maxn+10],t[maxn+10];

int main(){
  sx=read();
  sy=read();
  tx=read();
  ty=read();
  if(sx>tx)
    {
      std::swap(sx,tx);
      std::swap(sy,ty);
    }
  n=read();
  for(int i=1;i<=n;i++)
    {
      p[i].x=read();
      p[i].y=read();
    }
  if(sy>ty)
    {
      for(int i=1;i<=n;i++)
        {
          p[i].y=maxv-p[i].y;
        }
      sy=maxv-sy,ty=maxv-ty;
    }
  std::sort(p+1,p+n+1);
  ans=(ty+tx-sy-sx)*100.0;
  for(int i=1;i<=n;i++)
    {
      if(p[i].ft())
        {
          t[++tot]=p[i];
        }
    }
  memset(c,0x3f,sizeof(c));
  c[0]=cnt=0;
  for(int i=1;i<=tot;i++)
    {
      int l=1,r=cnt,md,res=0;
      while(l<=r)
        {
          md=((r+l)>>1);
          if(c[md]<t[i].y)
            {
              res=md;
              l=md+1;
            }
          else
            {
              r=md-1;
            }
        }
      if(res==cnt)
        {
          cnt++;
        }
      c[res+1]=std::min(c[res+1],t[i].y);
    }
  if(cnt<=tx-sx&&cnt<=ty-sy)
    {
      ans+=cnt*K;
    }
  else
    {
      ans+=(cnt-1)*K+D;
    }
  printf("%.13lf\n",ans);
  return 0;
}


Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int d= Integer.parseInt(sc.next());

		System.out.println(Math.max(a*b, c*d));
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main() {
    const double PI = 3.14159265358;
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double H = (h*30+m*0.5)/180*PI;
    double M = PI*m*6/180;
    double ax = a*cos(H);
    double ay = a*sin(H);
    double bx = b*cos(M);
    double by = b*sin(M);
    double ans = sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
    cout << fixed << setprecision(20) << ans << endl;
}


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

int main()
{
	ll n;
	cin>>n;
	ll ans[n];
	ll h[n];
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	ans[0] = 0;
	ans[1] = abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
	{
		ans[i] = min(ans[i-1]+abs(h[i]-h[i-1]), ans[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<ans[n-1]<<endl;
}

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

int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        if(i%2)continue;
        cout<<s[i];
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int a = Integer.parseInt(scan.nextLine());
        int b = Integer.parseInt(scan.nextLine());
        int c = Integer.parseInt(scan.nextLine());
        int x = Integer.parseInt(scan.nextLine());

        int count = 0;
        for (int i = 0; i < a + 1; i++) {
            for (int j = 0; j < b + 1; j++) {
                for (int k = 0; k < c + 1; k++) {
                    if (500 * i + 100 * j + 50 * k == x) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
first = true
while true
  price = gets.to_i
  break if price == 0
  coin_numbers = gets.split.map(&:to_i)
  puts if !first
  first = false
  coin_values = [10, 50, 100, 500]
  coins_and_values = coin_numbers.zip(coin_values)
  total_price = coins_and_values.inject(0){ |sum, pair|
    sum += pair[0] * pair[1]
  }
  change = total_price - price
  change_coins = []
  coin_values.reverse.each do |value|
    coin = change / value
    change = change % value
    change_coins.insert(0, coin)
  end
  temp_pairs = coin_numbers.zip(change_coins)
  actual_coins = temp_pairs.map {|pair| pair[0] > pair[1] ? pair[0] - pair[1] : 0}
  coin_values.zip(actual_coins).each do |zip|
    puts "#{zip[0]} #{zip[1]}" if zip[1] > 0
  end
end

Measured memory_bytes: 8908
import java.util.Scanner;

public class Main {

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

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

    int pattern = n;
    for (int i = 0; i < m - 1; i++) {
      pattern = pattern * (n - 1);
    }

    System.out.println(pattern);
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,a,yu,small=23333333,yunum=0,num;
	cin>>n>>x;
	yu=x;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		yu=yu-a;
		if(a<small) small=a;
	}
	yunum=yu/small;
	num=yunum+n;
	cout<<num<<endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;
/* -- template -- */
ll dp[100 + 1][100000 + 1]; // dp[i][w] iまでの中で，重さwを超えないように選んだときの最大
int main(){
    int N, W; cin >> N >> W;
    int w[N];
    ll v[N];
    rep(i, N)cin >> w[i] >> v[i];
    //dp[i][w + w[i]] = max(dp[i][w + w[i]], dp[i][w] + v[i]);
    for(int i = 0;i < N;++i){
        for(int wi = 0;wi <= W;++wi){
            dp[i + 1][wi] = dp[i][wi];
            if(wi - w[i] >= 0)
                dp[i + 1][wi] = max<ll>(dp[i][wi], dp[i][wi - w[i]] + v[i]);
        }
    }
    cout << dp[N][W];
}


Measured memory_bytes: 78336
#include <stdio.h>


int main(void){

	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a < b && b < c){
		
		printf("Yes\n");
		
	}else{
		
		printf("No\n");
		
	}
	return 0;
}	
	

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i=k;i<n;i++)
#define sum(start, end) accumulate(start, end, 0)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

using namespace std;
template <class T = ll> T in() { T _in; cin >> _in; return (_in); }


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

    ll A = in<ll>(), B = in<ll>(), K = in<ll>();

    REP(i, A, min(A+K, B)) // Kが大きい時に範囲外に飛んでいく対策
        cout << i << endl;
    REP(i, max(B-K+1, min(A+K, B)), B+1) // B-K+1から始めたいけど，A+Kとの重複をさける
        cout << i << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string S,T,U;
    int A,B;
    cin >> S >> T >> A >> B >> U;
    if(U==S){
        A--;
        cout << A << " " <<B;
    }else{
        B--;
        cout << A <<" "<<B;
    }
}

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

int main(){
    long long int n;
    while(cin >> n, n){
        long long int ans = 100000;
        for(long long int i=1; i*i*i <= n*n*n; i++){
            for(long long int j=1; i*i*i+j*j*j <= n*n*n; j++){
                ans = min(ans, n*n*n-i*i*i-j*j*j);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxx = 1010;
int c[maxx][maxx];

int lcs(char s1[],char s2[]) {
    int m = strlen(s1), n = strlen(s2);
    for (int i = 1; i <= m; i++)
        c[i][0] = 0;
    for (int i = 1; i <= n; i++)
        c[0][i] = 0;

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (s1[i] == s2[j])
                c[i+1][j+1] = c[i][j] + 1;
            else
                c[i+1][j+1] = max(c[i][j+1], c[i + 1][j]);
        }
    }
    return c[m][n];
}
int main()
{
    char s1[maxx], s2[maxx];
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; i++) {
        scanf("%s %s", s1, s2);
        printf("%d\n",lcs(s1,s2));
    }

    return 0;
}


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

int main() {

  while(1) {
    int x, y;
    cin >> x >> y;

    if ( x == 0 &&  y == 0 ) break;

    if ( x < y )
      cout << x << " " << y << endl;
    else
      cout << y << " " << x << endl;

  }

  return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[1000000];
int main(){
    int n,weight;
    cin>>n>>weight;
    int w[n],v[n];
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
   fill(dp,dp+1000000,1e9);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=sum;j>=v[i];j--){
                dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
        }
    }
   int ans=0;
    for(int i=0;i<=sum;i++){
       if(dp[i]<=weight)
           ans=max(ans,i);

    }

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



Measured memory_bytes: 8064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    long x = sc.nextLong();
    long k = sc.nextLong();
    long d = sc.nextLong();
    if (x < 0) x = -x;
    long m = x / d;
    if (m >= k) {
      System.out.println(x - k * d);
      return;
    }
    x -= m * d;
    k -= m;
    if (k % 2L == 0) {
      System.out.println(x);
    } else {
      System.out.println(d - x);
    }
  }
}

Measured memory_bytes: 32752