akhauriyash/Code-Regression huggingface dataset:
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

ll a, b, c;

map <pair <pii, int>, int> mapa;

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

  int move = 0;
  while (!mapa[mp(mp(a, b), c)]) {
    mapa[mp(mp(a, b), c)] = 1;
    if (a % 2 || b % 2 || c % 2) {
      cout << move << endl;
      return 0;
    }
    ll na = a / 2;
    ll nb = b / 2;
    ll nc = c / 2;
    a = nb + nc;
    b = na + nc;
    c = na + nb;
    move++;
  }

  puts("-1");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

    char[][] map;
    int[][] pos;
    int h, w, n;
    int[] dx = {0, 0, 1, -1};
    int[] dy = {1, -1, 0, 0};

    void solve(){
        Scanner sc = new Scanner(System.in);

        h = sc.nextInt();
        w = sc.nextInt();
        n = sc.nextInt();

        map = new char[h][w];
        pos = new int[n+1][2];

        for(int i=0; i<h; i++){
            char[] c = sc.next().toCharArray();
            for(int j=0; j<w; j++){
                map[i][j] = c[j];
                if(c[j]=='S'){
                    pos[0][0] = j; pos[0][1] = i;
                }
                if(Character.isDigit(c[j])){
                    pos[c[j]-'0'][0] = j; pos[c[j]-'0'][1] = i;
                }
            }
        }

        int sum = 0;
        for(int i=0; i<n; i++){
            int num = dijstra1(i, i+1);
            sum += num;
        }

        System.out.println(sum);
    }

    int dijstra1(int start, int goal){
        //x, y
        LinkedList<int[]> q = new LinkedList<int[]>();
        q.add(new int[]{pos[start][0], pos[start][1], 0});

        int[][] v = new int[h][w];

        while(q.size()>0){
            int[] xy = q.poll();
            int x = xy[0], y = xy[1];
            if(x==pos[goal][0] && y==pos[goal][1]) return v[y][x];

            for(int i=0; i<4; i++){
                int nx = x + dx[i], ny = y + dy[i];
                if(nx<0 || nx>=w || ny<0 || ny>=h || v[ny][nx]!=0
                   || map[ny][nx]=='X') continue;
                v[ny][nx] = v[y][x] + 1;
                q.add(new int[]{nx, ny});
            }
        }
        return -1;
    }

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

Measured memory_bytes: 98004
n = gets.to_i
arr = gets.split(' ').map(&:to_i).sort!.reverse!

sum_alice = 0
sum_bob   = 0

index = 0
begin
  sum_alice += arr[index]
  
  index += 1
  break if index == n
  
  sum_bob += arr[index]
  index += 1

end while n > index

p sum_alice - sum_bob

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  double n,t,a;
  cin>>n>>t>>a;
  vector<double> h(n);
  rep(i,n) cin>>h[i];
  double ans=0,mn=inf;
  rep(i,n){
    if(abs(a-mn)>abs(a-t+h[i]*0.006)){
      ans=i;
      mn=t-h[i]*0.006;
      //cout<<mn<<endl;
    }
    
  }
  cout<<ans+1<<endl;
}







Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

#define MOD 1000000007;

int main(void)
{
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i < N;i++) cin >> A.at(i);
  if (N==1) {cout << A[0] << endl; return 0;}
  // cout << A[1] << endl;

  unsigned long ans = 0;
  unsigned long sum_l = 0;
  for(int i=0; i < N -1; i++)
  {
    sum_l = (sum_l + A[i]) % MOD;
    ans += (sum_l * A[i+1]) % MOD;
  }
  ans =  ans % MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N;
    cin >> N;
    ll ans = 0;
    repd(i, 1, N + 1) {
        double tmp = i * 1.08;
        tmp *= 100;
        tmp /= 100;
        if ((int)tmp == N) ans = i;
    }
    if (ans == 0) cout << ":(" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
l = list(map(int,input().split()))
ans = 100000000000000
x = 0
S = sum(l)
for i in range(N-1):
  #print("l["+str(i)+"]="+str(l[0]))
  x = x + l[i]
  #print(x,S-x)
  ans = min(ans, abs(x - (S - x)))
  #print(ans)
print(ans)

Measured memory_bytes: 24824
n,m=map(int,input().split())
c=list(map(int,input().split()))
c.sort(reverse=True)
#print(c)

dp=[0]
for i in range(1,n+1):
    mini=float("inf")
    for num in c:
        if i-num>=0:
            mini=min(mini,dp[i-num]+1)
    dp.append(mini)

#print(dp)
print(dp[-1])


Measured memory_bytes: 7352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String[] tmp = br.readLine().split(" ");
			long h = Long.parseLong(tmp[0]);
			long w = Long.parseLong(tmp[1]);
			tmp = null;
			if (h == 0 && w == 0)break;
			else write(h, w);
		}
	}

	private static void write(long h, long w) {
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < w;i++){
			sb.append("#");
		}
		sb.append(String.format("%n"));
		String header = sb.toString();
		String footer = header;
		
		sb.delete(0, sb.length());
		
		sb.append("#");
		for(int i = 0;i < w - 2;i++){
			sb.append(".");
		}
		sb.append(String.format("#%n"));
		String body = sb.toString();
		
		sb.delete(0, sb.length());
		
		sb.append(header);
		for(int i = 0;i < h - 2;i++){
			sb.append(body);
		}
		sb.append(footer);
		System.out.println(sb.toString());
		sb = null;
	}
}

Measured memory_bytes: 18404
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    ll N;
    cin >> N;
    ll V[N];
    for(ll i = 0; i < N; i++) cin >> V[i];
    ll C[N];
    for(ll i = 0; i < N; i++) cin >> C[i];
    ll ans = 0;
    for(ll i = 0; i < N; i++)
        if(V[i] > C[i]) ans += V[i] - C[i];
    cout << ans << "\n";
    return 0;
} 


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

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
            int a = abc[0], b = abc[1], c = abc[2];
            Console.WriteLine(c - Math.Min(c,a - b));
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

int switch_on[105];

int main(){
	
	int A,B,C,D;

	scanf("%d %d %d %d",&A,&B,&C,&D);

	int i;

	for(i=A;i<=B;i++){
		switch_on[i]++;
	}
	for(i=C;i<=D;i++){
		switch_on[i]++;
	}

	int mi=0;
	int ma=0;

	for(i=0;i<=100;i++){
		if(switch_on[i]==2){
		mi=i;
		break;
		}
	}

	for(i=100;i>=0;i--){
		if(switch_on[i]==2){
		ma=i;
		break;
		}
	}

	printf("%d\n",ma-mi);
	
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str,strArray[];

		while(!(str=br.readLine()).equals("0")){
			int n = Integer.parseInt(str);
			int S[]=new int[n];
			int C[];

			int count=0;

			strArray = br.readLine().split(" ");

			for(int i=0; i<n; i++){
				S[i] = Integer.parseInt(strArray[i]);
			}


			while(true){
				C=new int[n];

				for(int i=0; i<n; i++){
					for(int j=0; j<n; j++){
						if(S[i] == S[j]){
							C[i]++;
						}
					}
				}

				if(Arrays.equals(C, S)){
					break;
				}else{
					S=C;
				}
				count++;

			}

			System.out.println(count);

			for(int i=0; i<n; i++){
				if(i != n-1){
					System.out.print(C[i] + " ");
				}else{
					System.out.println(C[i]);
				}
			}

		}
	}
}

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

long long N, A[3000];
static long long DP[3000][3000] = {};
bool used[3000][3000] = {};

long long DFS(long long L, long long R) {
	if (L == R) {
		return (N % 2 == 0 ? -A[L] : A[L]);
	}
	if (used[L][R]) return DP[L][R];
	long long RET;
	if ((R - L + 1) % 2 == N % 2) RET = max(DFS(L + 1, R) + A[L], DFS(L, R - 1) + A[R]);
	else RET = min(DFS(L + 1, R) - A[L], DFS(L, R - 1) - A[R]);
	used[L][R] = true;
	return DP[L][R] = RET;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	cout << DFS(0, N - 1) << endl;
}

Measured memory_bytes: 78336
N = int(input())
A = [int(i) for i in input().split()]
INF = 10**10
while True:
  num_alive = sum([1 if i>0 else 0 for i in A])
  #print("A:" + str(A))
  #print("num_alive: " + str(num_alive))
  if num_alive == 1:
    break
  else:
    min_A = INF
    for i in A:
      if i>0:
        min_A = min(i, min_A)
      else:
        pass
    min_A_idx = A.index(min_A)
    #print("min_A:{}, min_A_idx: {}".format(str(min_A), str(min_A_idx)))
    A = [ i % min_A if idx != min_A_idx else i for idx, i in enumerate(A)  ]
    
print(max(A))

Measured memory_bytes: 14224
#include<stdio.h>

int main(){
  int h,w;
  int i,j;

  while (1){
    scanf("%d %d", &h, &w);
    if(h==0 && w==0){
      break;
    }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(j==0 || j==w-1 || i==0 || i==h-1){
          printf("#");
        }
        else{
          printf(".");
        }
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2020
from collections import deque
n, m = map(int, input().split())
inf = 10**9
def bfs(start):
    dist = [inf for i in range((n+1) * 3)]
    que = deque()
    que.append(start)
    finished = set()
    dist[start] = 0
    while que:
        node = que.popleft()
        if node not in finished:
            finished.add(node)
            for i in adjacent_list[node]:
                dist[i] = min(dist[i], dist[node] + 1)
                que.append(i)
    return dist

adjacent_list = [[] for i in range((n+1)*3)]
for _ in range(m):
    u, v = map(int, input().split())
    for i in range(3):
        adjacent_list[u*3 + i].append(v*3 +((i+1)%3))
start, goal = map(int, input().split())
graph = bfs(start*3)
if graph[goal*3] != inf:
    print(int(graph[goal*3]) // 3)
else:
    print(-1)

Measured memory_bytes: 106212
local ior = io.input()
local n, m = ior:read("*n", "*n")
local hasinfo = {}
local pos = {}
local parent = {}
local grouplen = {}
local groupidxes = {}
for i = 1, n do parent[i], grouplen[i], groupidxes[i] = i, 1, {i} end
for i = 1, n do hasinfo[i], pos[i] = false, 0 end
local isok = true

function getroot(idx)
  while(parent[idx] ~= idx) do
    idx = parent[idx]
  end
  return idx
end

for i = 1, m do
  local l, r, d = ior:read("*n", "*n", "*n")
  if(isok) then
    local lr, rr = getroot(l), getroot(r)
    if(hasinfo[l] and hasinfo[r]) then
      if(lr ~= rr) then
        local diff = pos[r] - (pos[l] + d)
        if(grouplen[lr] < grouplen[rr]) then
          for j = 1, #groupidxes[lr] do
            local tmpidx = groupidxes[lr][j]
            table.insert(groupidxes[rr], tmpidx)
            pos[tmpidx] = pos[tmpidx] + diff
          end
          grouplen[rr] = grouplen[rr] + grouplen[lr]
          grouplen[lr] = 0
          parent[l], parent[r], parent[lr] = rr, rr, rr
        else
          for j = 1, #groupidxes[rr] do
            local tmpidx = groupidxes[rr][j]
            table.insert(groupidxes[lr], tmpidx)
            pos[tmpidx] = pos[tmpidx] - diff
          end
          grouplen[lr] = grouplen[rr] + grouplen[lr]
          grouplen[rr] = 0
          parent[l], parent[r], parent[rr] = lr, lr, lr
        end
      else
        parent[l], parent[r], parent[lr] = rr, rr, rr
        isok = (d == pos[r] - pos[l])
      end
    elseif(hasinfo[r]) then
      parent[l], parent[r], parent[lr] = rr, rr, rr
      grouplen[l] = 0
      grouplen[rr] = grouplen[rr] + 1
      table.insert(groupidxes[rr], l)
      hasinfo[l] = true
      pos[l] = pos[r] - d
    elseif(hasinfo[l]) then
      parent[l], parent[r], parent[rr] = lr, lr, lr
      grouplen[lr] = grouplen[lr] + 1
      grouplen[r] = 0
      table.insert(groupidxes[lr], r)
      hasinfo[r] = true
      pos[r] = pos[l] + d
    else
      parent[l], parent[r], parent[rr] = lr, lr, lr
      grouplen[l] = 2
      grouplen[r] = 0
      table.insert(groupidxes[l], r)
      hasinfo[l], hasinfo[r] = true, true
      pos[l] = 0
      pos[r] = d
    end
  end
end
print(isok and "Yes" or "No")


Measured memory_bytes: 19812
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

char s[200005];

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

  scanf("%s", s);
  int n = strlen(s);
  int t = 0;
  for (int i = 0; i < n; i++) {
    t += s[i] - '0';
  }
  if (t % 9 == 0) puts("Yes");
  else puts("No");

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) * 1.0 / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define vvv(type, c, m, n, l, i) vector<vector<vector<type>>> c(m, vector<vector<type>>(n, vector<type>(l, i)));
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	string s;
	map<char, int> mc;
	while(getline(cin, s)) {
		if(s == "") break;
		rep(i, 0, len(s)) {
			++mc[tolower(s[i])];
		}
	}
	rep(i, 'a', 'z' + 1) {
		cout << char(i) << " : " << mc[char(i)] << endl;
	}
	return 0;
}

Measured memory_bytes: 3164
A, B, M = map(int, input().split())

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

miniC = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    miniC = min(miniC, a[x] + b[y] - c)

print(miniC)

Measured memory_bytes: 18736
import java.util.*;

class Main{
    private static int[][] ab;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] A = new int[N+1][N+1];
        //int[][] B = new int[N+1][N+1];
        for(int row=1;row<=N;row++){
            for(int col=1;col<=N;col++){
                A[row][col] = sc.nextInt();
            }
        }
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                for(int k=1;k<=N;k++){
                    if(A[j][k]>A[j][i]+A[i][k]){
                        System.out.println(-1);
                        System.exit(0);
                    }
                }
            }
        }
        long ans = 0;
        for(int i=1;i<N;i++){
            for(int j=i+1;j<=N;j++){
                boolean flag = true;
                for(int k=1;k<=N;k++){
                    if(k==i||k==j) continue;
                    if(A[i][j]==A[i][k]+A[k][j]){
                        flag = false;
                        break;
                    }
                }
                if(flag) ans += A[i][j];
            }
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 50796
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	vector<int>a;
	vector<int>b;
	vector<int>c;
	int k;
	int n;
	int x;
	int ans = 0;

	scanf("%d", &n);
	f(i, n){
		scanf("%d", &x);
		a.push_back(x);
	}
	sort(a.begin(), a.end());
	k = 0;
	f(i, n){
		if (i == 0){
			b.push_back(a[0]);
			c.push_back(1);
		}
		else{
			if (a[i] == a[i - 1]){
				c[k]++;
			}
			else{
				k++;
				b.push_back(a[i]);
				c.push_back(1);
			}
		}
	}
	f(i, b.size()){
		if (b[i] <= c[i])ans += c[i] - b[i];
		else ans += c[i];
	}

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

	return 0;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ');
			var a = long.Parse(firstLine[0]);
			var op = firstLine[1];
			var b = long.Parse(firstLine[2]);

			if(op == "+")
			{
				Console.WriteLine(a + b);
			}
			else
			{
				Console.WriteLine(a - b);
			}
		}
	}
}


Measured memory_bytes: 11092
n = int(input())
m_list = []
for i in range(n):
    x,l = map(int, input().split())
    m_list.append([x-l, x+l])

m_list = sorted(m_list,key= lambda x:x[1])

result = 0
cur_pos = -1000000000

for min,max in m_list:
    if cur_pos <= min:
        result += 1
        cur_pos = max
print(result)

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

int main(){
    int n;  cin >> n;
    vector<pair<int,int>> p(n+1);
    ll all=0;
    for(int i=1;i<=n;i++){
        cin >> p.at(i).second >> p.at(i).first ;
        all += p.at(i).second;
    }
    sort(p.begin(),p.end());

    for(int i=n;i>0;i--){
        if(all > p.at(i).first){
            cout << "No" << endl;
            return 0;
        }
        all -= p.at(i).second;
        p.erase(p.begin()+i);
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

    private static final int r     =  0,
    		                 c     =  1,
    		                 EMPTY = -1;

    private static int[]   p;
    private static int[][] m;

    public static void main(String[] args) {

        //input
         Scanner sc = new Scanner(System.in).useDelimiter(System.getProperty("line.separator"));
         int N = sc.nextInt();
         p = new int[N+1];
         m = new int[N][N];
         String[] s = null;
       	 for(int i=0;i<N;i++){
       		 s = sc.next().split("\\s");
       		 p[i] = Integer.parseInt(s[r]);
       	 }
       	 p[N] = Integer.parseInt(s[c]);

         //calculation
       	 int i,j,k,l,q;
       	 for(l=1;l<N;l++){
       		 for(i=0;i<N-l;i++){
       			 j = i + l;
       			 m[i][j] = EMPTY;
       			 for(k=i;k<j;k++){
       				 q = m[i][k] + m[k+1][j] + p[i]*p[k+1]*p[j+1];
       				 if(q < m[i][j] || m[i][j] == EMPTY){
       					 m[i][j] = q;
       				 }
       			 }
       		 }
       	 }

         //output
       	 System.out.println(m[0][N-1]);
    }
}

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

int main() {
    string S;cin >> S;
    int N;N = S.size();
    int N2 = (N - 1) / 2;
    string A = S.substr(0,N2);
    string B = S.substr(N2 + 1,N2);
    int flag = 0;
    if (N2 % 2 == 0){
        for (int i = 0;i < (N2 / 2);i++){
            if (A[i] != A[N2 - 1 - i]) flag = 1;
            if (B[i] != B[N2 - 1 - i]) flag = 1;
        }
    }
    else {
        for (int i = 0;i < ((N2 - 1) / 2);i++){
            if (A[i] != A[N2 - 1 - i]) flag = 1;
            if (B[i] != B[N2 - 1 - i]) flag = 1;
        }
    }
    for (int i = 0;i < N2;i++){
        if (S[i] != S[N - 1 - i]) flag = 1;
    }
    if (flag == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define P pair<string,int>
using namespace std;
bool match(string s, string t)
{
  int i;
  for(i=0;i<8;i++){
    if(t[i] != '*' && t[i] != s[i]) break;
  }
  return i == 8;
}
int main()
{
  int n, m, t;
  string s;
  while(cin >> n >> m, n){
    vector< P > v;
    while(n--){
      cin >> s >> t;
      v.push_back( P(s,t) );
    }
    t = 0;
    while(m--){
      cin >> s;
      vector< P >::iterator it = v.begin();
      while(it != v.end()){
	if(match(s,(*it).first)){
	  t += (*it).second;
	}
	it++;
      }
    }
    cout << t << endl;
  }
  return 0;
}

Measured memory_bytes: 936
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int maxn= 350;
bool vis[maxn];
int mapp[maxn][maxn];
int n,m;
int num[maxn];
int main()
{
    scanf("%d%d",&n,&m);
    for(register int i=1;i<=n;i++)
    {
        for(register int j=1;j<=m;j++)
        {
            scanf("%d",&mapp[i][j]);
        }
    }
    int qq=m;
    int minn=1e9+7;
    memset(vis,1,sizeof(vis));
    while(qq--)
    {
        memset(num,0,sizeof(num));
        int maxx=0,no;
        for(register int i=1;i<=n;i++)
        {
            for(register int j=1;j<=m;j++)
            {
                if(vis[mapp[i][j]])
                {
                    num[mapp[i][j]]++;
                    if(num[mapp[i][j]]>maxx)
                    {
                        maxx=num[mapp[i][j]];
                        no=mapp[i][j];
                    }
                    break;
                }
            }
        }
        vis[no]=false;
        minn=min(minn,maxx);
    }
    printf("%d\n",minn);
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<unordered_map>
#include<algorithm>
/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
	ios::sync_with_stdio(0);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
//===============================================
#define ll long long
#define ld double
#define mk make_pair
#define loop(i,intial,n)  for(int i=(intial);i<n;i++)
#define loopn(j,n) for(int j=int(n);j>=0;j--)
#define loopm(name)  for(auto it : name)
#define loopm2(name)  for(auto it2 : name)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
#define PI (ld)(3.14159265358979323846)
//===============================================
#define SF(a) scanf("%d",&a)
#define SF2(a,b) scanf("%d %d",&a,&b)
#define SFLL(a) scanf("%lld",&a)
#define SFLL2(a,b) scanf("%lld %lld",&a,&b)
#define PF(a) printf("%d\n",a)
#define PFLL(a) printf("%lld\n",a)
//===============================================
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const double EPS = 1e-4;
const ll oo = (ll) 10e9 + 7;
const ll N = 1e5 + 18;
const ll mod = 1000003;
//int dx[] = { 0, 1, 0, -1 };
//int dy[] = { 1, 0, -1, 0 }; // 4 Direction*/
//int dx[]={1,1,0,-1,-1,-1,0,1};
//int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction*/
//freopen("largest.in", "r", stdin);
//freopen("output.txt", "w", stdout);
//ifstream ifs("input.txt");
//ofstream ofs("output.txt");

int main()
{
	afify();
	string s;
	cin >> s;
	cout << "ABC" << s << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace X_Cubic
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Math.Pow(int.Parse(Console.ReadLine()), 3));
        }
    }
}



Measured memory_bytes: 15892
# coding: utf-8
# Your code here!

str = input().strip()
flag = True

for i in range(len(str)):
    if i % 2 == 0:
        if str[i] == 'L':
            flag = False
            break
    else:
        if str[i] == 'R':
            flag = False
            break
        
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
//https://atcoder.jp/…/nikkei2019-qual/tasks/nikkei2019_qual_d

#include <bits/stdc++.h>

using namespace std;

#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio { ios_base::sync_with_stdio(false), cin.tie(NULL); }
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#ifdef RICARDO
//Header here
	#include "E:\\Code\\dbg.h"
#else
	#define bug(...) "RICARDO MILOS"
#endif


template<class T> bool mini(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool maxi(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

//=================================================CODE=================================================//

signed main()
{	
	fastio;
	cout.precision(10);
	cout << fixed;
#ifdef RICARDO		
	freopen("i", "r", stdin);
#endif
	int n, m; cin >> n >> m;
	m += n - 1;
	vvi G(n);
	forn(i, m) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[v].pb(u);
	}

	vi par(n, -1);
	vi h(n, -1);
	function<void(int)> dfs = [&](int u) {
		if((int) G[u].size() == 0) {
			h[u] = 0;
			return;
		}
		for(int v : G[u]) {
			if(h[v] < 0) dfs(v);				
			if(maxi(h[u], h[v] + 1)) par[u] = v;
		}
	};

	forn(i, n) {
		if(par[i] < 0) dfs(i);
		cout << par[i] + 1 << endl;		
	}
#ifdef RICARDO
	cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}

Measured memory_bytes: 12032
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <bits/stdc++.h>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob push_back
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
using namespace std;
typedef long long ll;
typedef long double ld;
ll N;
vector<vector<ll> > ans;
void fail(){
  cout << "No" << endl;
  exit(0);
}
int main() {
  cout << fixed << setprecision(10);
  N = getll();
  ll k=0;
  REP(i,N+10)
    if (N*2==i*(i+1))
      k=i+1;
  if (k==0)
    fail();
  ans.resize(k);

  REP(i,k) {
    ll p=(k-1+k-i)*i/2;
    REP(j,k-i-1) {
      ans[i].pb(p+j);
      ans[i+j+1].pb(p+j);
    }
  }

  pr("Yes");
  pr(BR);
  cout << k << endl;
  REP(i,k) {
    prl(k-1);
    pr(" ");
    FEACH(it, ans[i]){
      prl(*it+1);pr(" ");
    }
    pr(BR);
  }
  return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <math.h>

int is_prim(int input);

int main(int argc, char const *argv[])
{
  int input,n,i, count;
  scanf("%d", &n);
  for(i=0;i<n;i++) {
    scanf("%d", &input);
    if(is_prim(input)==1)
      count++;
  }
  printf("%d\n",count);
  return 0;
}

int is_prim(int input)
{
  int i;

  if(input==2)
    return 1;
  if(input< 2||input%2==0)
    return 0;
  i = 3;
  while(i<=sqrt(input)) {
    if(input%i==0)
      return 0;
    i = i+2;
  }
  return 1;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi pair<int, int>
#define pl pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define MOD ll(1000000007)

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

	ll d, i, n, j, t, m, x, y, z, k;

	ll ans=0;

	cin>>x>>k>>d;
	x=abs(x);

	ll quo = x/d;
	if(quo>=k)
		ans=x-(k*d);
	else{
		m=x%d;
		if((k-quo)&1)
			ans=abs(d-m);
		else
			ans=abs(m);
	}
	
	cout<<ans;
	cout<<"\n";



	return 0;
}


Measured memory_bytes: 3612
#!/usr/bin/env python

import sys

n,m = [ int(x) for x in sys.stdin.readline().split() ]
k = dict()
for x in sys.stdin.readline().split():
    x = int(x)
    k[x]= k.get(x,0) + 1
#
for i in range(m):
    bi, ci= [ int(x) for x in sys.stdin.readline().split() ]
    k[ci]= k.get(ci,0) + bi
    #ai+= [ci]*bi
#
s = 0
rest= n
for val in sorted( k.keys(),reverse=True ):
    num = k[val]
    if rest>num:
        s+= num * val
        rest-= num
    else:
        s+= val * rest
        break
print( s )


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

int N, C, K;
int T[1000010];

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

    for (int i = 0; i < N; i++)
    {
        scanf("%d", &T[i]);
    }

    sort(T, T + N);

    int cnt = 0;
    for (int i = 0; i < N;)
    {
        int j = 0;
        while (i + j < N && T[i+j] - T[i] <= K && j < C)
        {
            j++; 
        }
        i += j;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

int main()
{
   ll a,b,c,d;
   scanf("%lld %lld",&a,&b);
   c=(a+b);
   if(c%2!=0)
   {
       printf("IMPOSSIBLE\n");
   }
   else
   {
       printf("%lld\n",c/2);
   }

}


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll q = n / (a + b);
  n -= q * (a + b);

  ll ans = q * a + min(n, a);

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n, nr,x;
int main()
{
    cin>>n;
    nr=0;
    for(int i=1; i<=n; ++i)
    {
        cin>>x;
        if(x==(nr+1))
            nr++;
    }
    if(nr)
    cout<<n-nr<<'\n';
    else cout<<-1<<'\n';
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353LL;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
ll k;
ll ans;
ll now;

void solve()
{
    cin >> k;
    if (k % 2 == 0 || k % 5 == 0)
        return puts("-1"), void();
    ans = 1, now = 7;
    while (1)
    {
        if (now % k == 0)
            break;
        ans++;
        now = (now * 10) + 7;
        now %= k;
    }
    printf("%lld\n", ans);
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include "math.h"

using namespace std;

int n, m;

int main() {
    
    cin >> n >> m;
    
    vector<int> menu(m, 0);
    
    int k;
    int a;
    
    for (int i = 0; i<n; i++) {
        cin >> k;
        for (int j = 0; j<k; j++) {
            cin >> a;
            menu[a-1] += 1;
        }
    }

    int res=0;
    
    for (int i=0; i<m; i++) {
        if (menu[i] == n) {
            res += 1;
        }
    }
    
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if(min(B,D)-max(A,C)>0){
    cout<<min(B,D)-max(A,C)<<endl;
  }
  else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
    int n,q,l,r;
    cin >> n >> q;
    string s;
    cin >> s;
    int freq[n];
    freq[0] = 0;

    for(int i = 1;i < n;i++){
        if(s[i - 1] == 'A' && s[i] == 'C'){
            freq[i] = freq[i - 1] + 1;
        }else
            {
                freq[i] = freq[i - 1];
            }
    }
    for(int i = 0;i < q;i++){
        cin >> l >> r;
        if(l == 1)
        cout << freq[r - 1] << endl;
        else
        {
        cout << freq[r - 1] - freq[l - 1] << endl;
        }
        
    }
            return 0;
        }
    

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>

using namespace std;

#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;

#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

const int N = int(2e5)+10;
const int K = int(2e6)+10;
// const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 2e18;

// const ll MOD = 1e9 + 7;
// inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
// inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

ll a[N];
map<ll,int> mp;

void solve () {
    int n;cin>>n;
    ll tots = 0;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        tots ^= a[i];
    }
    for (int i=1;i<=n;i++) {
        a[i] = tots ^ a[i];
        cout<<a[i]<<" ";
    }
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5152
#include<bits/stdc++.h>                          
using namespace std;
int n,sum,a[100005];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
	a[0]=0,a[n+1]=0;
    for(int i=1;i<=n+1;i++) sum+=abs(a[i]-a[i-1]);
    for(int i=1;i<=n;i++)
	{
        int t1=abs(a[i+1]-a[i]);
        int t2=abs(a[i]-a[i-1]);
        int t3=abs(a[i+1]-a[i-1]);
        cout<<sum-t1-t2+t3<<endl;
    }
    return 0;
}

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

template<class E>
using nega_queue = priority_queue<E,vector<E>,greater<E>>;

struct Node{
 string X;
 bool way;
 LL cost;
 bool operator>(const Node&r) const{
  if(cost!=r.cost) return cost>r.cost;
  return false;
 }
};

int N;
pair<string,LL> S[50];
pair<string,LL> rS[50];
set<pair<string,bool>> F;
map<string,LL> Fin;
map<string,LL> rFin;

bool isPalin(const string& s){
 string t=s; reverse(t.begin(),t.end());
 return s==t;
}

void addFin(const string& s, LL c){
 for(int i=0; i<=s.size(); i++){
  string tg = s.substr(i,string::npos);
  if(!isPalin(tg)) continue;
  LL buf = Fin[s.substr(0,i)];
  if(buf==0) buf=c; else buf=min(buf,c);
  Fin[s.substr(0,i)] = buf;
 }
}
void addrFin(const string& s, LL c){
 for(int i=0; i<=s.size(); i++){
  string tg = s.substr(i,string::npos);
  if(!isPalin(tg)) continue;
  LL buf = rFin[s.substr(0,i)];
  if(buf==0) buf=c; else buf=min(buf,c);
  rFin[s.substr(0,i)] = buf;
 }
}

int main() {
 cin>>N; rep(i,N) cin>>S[i].first>>S[i].second;

 rep(i,N){
  rS[i] = S[i]; reverse(rS[i].first.begin(),rS[i].first.end());
  addFin(S[i].first,S[i].second);
  addrFin(rS[i].first,rS[i].second);
 }

 nega_queue<Node> Q;
 for(auto& p:Fin){ if(p.first=="") Q.push({"",false,p.second}); }
 rep(i,N) Q.push({rS[i].first,false,rS[i].second});
 rep(i,N) Q.push({S[i].first,true,S[i].second});

 LL ans=-1;

 while(Q.size()){
  Node v = Q.top(); Q.pop();
  if(F.count({v.X,v.way})) continue;
  if(isPalin(v.X)){ ans=v.cost; break; }
  F.insert({v.X,v.way});

  rep(i,N){
   Node buf;
   if(!v.way){
    if(v.X.size() < S[i].first.size()){
     if(v.X != S[i].first.substr(0,v.X.size())) continue;
     buf.X = S[i].first.substr(v.X.size(),string::npos);
     buf.way = true;
     buf.cost = v.cost+S[i].second;
    }
    else{
     if(v.X.substr(0,S[i].first.size()) != S[i].first) continue;
     buf.X = v.X.substr(S[i].first.size(),string::npos);
     buf.way = false;
     buf.cost = v.cost+S[i].second;
    }
   }
   else {
    if(v.X.size() < rS[i].first.size()){
     if(v.X != rS[i].first.substr(0,v.X.size())) continue;
     buf.X = rS[i].first.substr(v.X.size(),string::npos);
     buf.way = false;
     buf.cost = v.cost+rS[i].second;
    }
    else{
     if(v.X.substr(0,rS[i].first.size()) != rS[i].first) continue;
     buf.X = v.X.substr(rS[i].first.size(),string::npos);
     buf.way = true;
     buf.cost = v.cost+rS[i].second;
    }
   }
   Q.push(buf);

   if(!v.way){
    if(Fin.count(v.X)){
     buf = {"",false,v.cost+Fin[v.X]};
     Q.push(buf);
    }
   }
   else{
    if(rFin.count(v.X)){
     buf = {"",false,v.cost+rFin[v.X]};
     Q.push(buf);
    }
   }

  }
 }

 cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 3688
n,m = map(int, input().split())
f = [1] 
p = 10**9 + 7
for i in range(1, max(n,m) + 1):
  f.append(f[-1] * i % p)

if abs(n-m) == 1:
  print(f[n] * f[m] % p)
elif abs(n-m) == 0:
  print(f[n] * f[m] * 2 % p)
else:
  print(0)


Measured memory_bytes: 12844
<?php

fscanf(STDIN, '%d', $A);
fscanf(STDIN, '%d', $B);
fscanf(STDIN, '%d', $C);
fscanf(STDIN, '%d', $D);
fscanf(STDIN, '%d', $E);


$amariLast = 10;
$last = $A;
foreach ([$A, $B, $C, $D, $E] as $val) {
    $amari = $val % 10;
    if ($amari < $amariLast && $amari !== 0) {
        $last = $val;
        $amariLast = $amari;
    }
}

$ans = 0;
foreach ([$A, $B, $C, $D, $E] as $val) {
    if ($val < 10) {
        $ans += 10;
    } else {
        $ans += (ceil($val / 10) * 10);
    }
}
$ans -= (10 - $amariLast);

echo intval($ans) . PHP_EOL;

Measured memory_bytes: 4728
s = input()
t = input()
if len(s) >= len(t):
  temp = -1
  for i in range(len(s) - len(t) + 1)[: : -1]:
    temp = i
    for j in range(len(t)):
  	  #print(s[i + j], t[j])
  	  if (s[i + j] == "?") or (s[i + j] == t[j]):
  	    continue
  	  else: 
  	  	temp = -1
    if temp != -1:
      #print(temp)
      break
  if temp == -1: print("UNRESTORABLE"); exit(0)
  r = (s[: temp] + t + s[temp + len(t): ]).replace("?", "a")
  print(r)
else: print("UNRESTORABLE")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"
#define mod 1000000007

int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	string s,t,p;
	cin>>s>>t;
	s+=s;
	cout<<(s.find(t)!=-1?"Yes":"No");

}

Measured memory_bytes: 3660
// A. 

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	LL q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	LL a = n / 2;
	LL b = min(min(q * 8, h * 4), min(s * 2, d));
	LL ans = a * b;
	a = n - a * 2;
	b = min(min(q * 4, h * 2), s);
	ans += a * b;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
#define INF 0x3f3f3f3f
typedef long long ll;
typedef pair<int, int> ii;

int main(void) {
	ios_base::sync_with_stdio(false);

	ll n, a, b; cin >> n >> a >> b;

	cout << (n-a)%b<<endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, M = list(map(int, input().split()))

# 行の先頭を除去するために[1:]をしてる｡
a = [list(map(int, input().split()))[1:] for i in range(N)]

# flatten
a = sum(a, [])

# print(a)

import collections

a = collections.Counter(a)

a = list(a.items())

# print(a)

count = 0

for i, j in a:
    if j >= N:
        count += 1

print(count)


Measured memory_bytes: 3316
# include<bits/stdc++.h>
# include<unordered_map>
# include<unordered_set>
//# include<prettyprint.hpp>
using namespace std;
# define ll long long
# define endl '\n'
int h, w, k;
int count(string x, string y, vector<string> g){
    for(int i = 0; i < x.size(); i++){
        if (x[i] == '0') continue;
        for(int j = 0; j < w; j++) g[i][j] = '$';
    }
    for(int i = 0; i < y.size(); i++){
        if (y[i] == '0') continue;
        for(int j = 0; j < h; j++) g[j][i] = '$';
    }
    int res = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) if (g[i][j] == '#') res++;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> h >> w >> k;
    int ans = 0;
    vector<string> g(h);
    for(int i = 0; i < h; i++) cin >> g[i];
    for(int i = 0; i < (1 << h); i++){
        for(int j = 0; j < (1 << w); j++){
            string x, y;
            int xval = i, yval = j;
            while (xval){
                if (xval&1) x+='1';
                else x+='0';
                xval>>=1;
            }
            while (yval){
                if (yval&1) y+='1';
                else y+='0';
                yval>>=1;
            }
            if (count(x, y, g) == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    long long n, k;
    scanf("%lld %lld", &n, &k);
    long long pos, neg;
    pos = n % k;
    neg = std::abs(pos - k);
    if (pos < neg)
    {
        printf("%lld", pos);
    }
    else
    {
        printf("%lld", neg);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string A, B;
    cin >> A >> B;
    int len = A.size();
    int ans = 0;
    for (int i = 0; i < len; i++)
        ans += A[i] != B[i];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3836
#069_D
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

s = []
for i in range(n):
    s += [i+1] * a[i]
    
for i in range(h):
    if i % 2 == 0:
        print(*s[i*w: (i+1)*w])
    else:
        print(*s[i*w: (i+1)*w][::-1])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    int N,M;cin >> N >> M;
    int a[M],b[M];
    vector<pair<int,int>> V;
    REP(i,M){
        cin >> a[i] >> b[i];
        V.pb({b[i],a[i]});
    }
    sort ALL(V);
    int ans = 1,key = V[0].first;
    REPP(i,1,M){
        if(key <= V[i].second){
            ans++;
            key = V[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1912
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

struct UnionFind {
    vector<int> par; 
    vector<int> sizes;
    UnionFind(int N) : par(N),sizes(N,1) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y); 
        if (rx == ry) return; 
        if (sizes[rx]<sizes[ry])swap(rx,ry);
        // xがyの親になるように連結する
        par[ry] = rx; 
        sizes[rx]+=sizes[ry];
    }

    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int size(int x){
        return sizes[root(x)];
    }

};

int ans;
int n,m;
int a[111111];
int x[111111],y[111111];

signed main(){
    
    
    cin>>n>>m;
    UnionFind uf(n+2);
    rep(i,n){
    	cin>>a[i];
    	a[i]--;
    }
    rep(i,m){
    	cin>>x[i]>>y[i];
    	x[i]--;y[i]--;
    	uf.unite(x[i],y[i]);
    }
    
    rep(i,n){
    	if(uf.same(i,a[i]))ans++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 4224