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


int main()
{
    string s;

    cin>>s;
   bool ok=false;
    for(int i=0;i<3;i++){
        if(s[i]=='7'){
            ok=true;
        }
    }

    if(ok)cout<<"Yes"<<endl;
    else  cout<<"No"<<endl;



    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
	int n,m,k;
	int[] A = new int[205];
	int[] B = new int[205];
	Scanner in = new Scanner(System.in);

	n = in.nextInt();
	for(int i=1;i<=2*n;i++)A[i] = i;
	m = in.nextInt();
	for(int i=0;i<m;i++)
	    {
		k = in.nextInt();
		if(k == 0)
		    {
			int d = 1;
			for(int j=1;j<=2*n;j+=2)
			    {
				//System.out.println("j = " + j);
				if(j != 1)d++;;
				B[j] = A[d];
				B[j+1] = A[n+d];
				//for(int l=1;l<=2*n;l++)System.out.println(B[l]);
			    }		
			for(int j=1;j<=2*n;j++)A[j] = B[j];
			//for(int l=1;l<=2*n;l++)System.out.println(B[l]);
		    }
		else
		    {
			for(int j=1;j<=2*n;j++)
			    {
				if(j<=k)
				    {
					B[(2*n-k)+j] = A[j];
				    }
				else    B[j - k] = A[j];

			    }
			for(int j=1;j<=2*n;j++)A[j] = B[j];
			//for(int l=1;l<=2*n;l++)System.out.println(B[l]);
		    }


	    }

	for(int i=1;i<=2*n;i++)System.out.println(A[i]);
    }
}

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

int cnt(int n) {
    int ret = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret++;
            if (n / i != i) {
                ret++;
            }
        }
    }
    return ret;
}

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

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


Measured memory_bytes: 256
W, H = [int(_) for _ in input().split()]
S = []
for _ in range(W):
    S += [(int(input()), 0)]
for _ in range(H):
    S += [(int(input()), 1)]
S.sort()
ans = w = h = 0
for c, d in S:
    if d:
        ans += c * (W + 1 - w)
        h += 1
    else:
        ans += c * (H + 1 - h)
        w += 1
print(ans)


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

int bl[2010][2010], wh[2010][2010];

int main() {
	int N, K;
	cin >> N >> K;
	for(int i=0; i<N; ++i){
		int x, y;
		char c;
		cin >> x >> y >> c;
		if(c=='B') ++bl[x%(K*2)][y%(K*2)+1];
		else ++wh[x%(K*2)][y%(K*2)+1];
	}
	for(int i=0; i<K*2; ++i){
		for(int j=0; j<K*2; ++j){
			bl[i][j+1] += bl[i][j];
			wh[i][j+1] += wh[i][j];
		}
	}
	int ans=0;
	for(int i=0; i<K; ++i){
		int now=0;
		for(int j=0; j<K*2; ++j){
			if(j<K){
				now += bl[j][i+K]-bl[j][i];
				now += wh[j][K*2]-(wh[j][i+K]-wh[j][i]);
			}else{
				now += wh[j][i+K]-wh[j][i];
				now += bl[j][K*2]-(bl[j][i+K]-bl[j][i]);
			}
		}
		for(int j=0; j<K*2; ++j){
			now -= bl[j][i+K]-bl[j][i];
			now -= bl[(j+K)%(K*2)][K*2]-(bl[(j+K)%(K*2)][i+K]-bl[(j+K)%(K*2)][i]);
			now -= wh[(j+K)%(K*2)][i+K]-wh[(j+K)%(K*2)][i];
			now -= wh[j][K*2]-(wh[j][i+K]-wh[j][i]);
			now += wh[j][i+K]-wh[j][i];
			now += wh[(j+K)%(K*2)][K*2]-(wh[(j+K)%(K*2)][i+K]-wh[(j+K)%(K*2)][i]);
			now += bl[(j+K)%(K*2)][i+K]-bl[(j+K)%(K*2)][i];
			now += bl[j][K*2]-(bl[j][i+K]-bl[j][i]);
			ans=max(ans, now);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 31744
import math

N = int(input())
A = list(map(int, input().split()))
# print(N, A)

_A = [A[i] - (i + 1) for i in range(len(A))]
_A.sort()
median = _A[math.floor(len(A) / 2)]

sadness = 0
for i in range(len(A)):
    sadness += abs(A[i] - (i + 1 + median))

print(sadness)


Measured memory_bytes: 26832
import sys
import heapq
from collections import Counter
from math import sqrt

n = int(input())
a_s = [int(i) for i in sys.stdin.readline().split()]
a_s.sort()
_max = max(a_s)
ct = Counter(a_s)
cnt = 0
ls = [False] * (10**6+1)
for a in a_s:
    if ls[a]:
        cnt += 1
        continue
    elif ct[a] > 1:
        cnt += 1
    for i in range(a, _max+1, a):
        if ls[i]:
            continue
        if i % a == 0:
            ls[i] = True

print(n - cnt)

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

int main()
{
    int n,i,j,k;
    char a,b,c,d;
    scanf("%c",&a);
    switch(a)
    {
        case'A':printf("T\n");break;
        case'T':printf("A\n");break;
        case'C':printf("G\n");break;
        case'G':printf("C\n");break;

    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
ll l=1000000007;
string alphabet="abcdefghijklmnopqrstuvwxyz";
using graph = vector<vector<int>>;
double pi=3.14159265358979;
int main() {
  int n,m; cin>>n>>m;
  graph v(m);
  rep(i,m){
    int k; cin>>k;
    rep(j,k){
      int s; cin>>s; s--;
      v[i].push_back(s);
    }
  }
  vector<int> p(m);
  rep(i,m){cin>>p[i];}
  int ans=0;
  for(int tmp=0;  tmp<(1<<10); tmp++){
    bitset<10> bs(tmp);
    
    bool b=true;
    rep(i,m){
      int c=0; 
      for(int j: v[i]){c+=bs[j];}
      c %=2;
      if(c!=p[i]){b=false;break;}
    }
    if(b){ans++;}
  }
  int x= pow(2,10-n);
  cout<<ans/x;
}

Measured memory_bytes: 3960
N = int(input())

dict = dict()

written_max = 0

for i in range(N):
	s = input()
	if s in dict:
		dict[s] += 1
	else:
		dict[s] = 1
	written_max = max(written_max,dict[s])

dict_sorted = sorted(dict.items(), key=lambda x:x[0])

for item in dict_sorted:
	if item[1] == written_max:
		print(item[0])


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

using namespace std;

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


Measured memory_bytes: 512
#include <stdio.h>
#define Max 2000000
int H,A[Max+1];

void MaxHeapify(int i){
  int l,r,largest,temp;
  l=2*i;
  r=2*i+1;

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

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

int main(){
  int i;

  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--) MaxHeapify(i);
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
ll i,j,k;
ll n,m;
ll ans=0;
ll a[300005];

int main(){
	cin>>n;
	for(i=0;i<3*n;i++){
		cin>>a[i];
	}
	sort(a,a+3*n);
	reverse(a,a+3*n);
	j=1;
	for(i=0;i<n;i++){
		ans += a[j];
		j+=2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7296
object Main extends App {

  def solve(n: Int, es: Seq[String]): Int = {
    Stream.from(n).find(_.toString.forall(d => !es.contains(d.toString))).get
  }

  val sc = new java.util.Scanner(Console.in)
  val n, k = sc.nextInt()
  val exclude = { for (_ <- 1 to k) yield sc.next() }.toVector

  println(solve(n, exclude))
}

Measured memory_bytes: 38684
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e9;
const long long LINF = 1LL << 50;
#define int long long

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	const int dx = c - a, dy = d - b;
	cout << string(dy, 'U') << string(dx, 'R');
	cout << string(dy, 'D') << string(dx, 'L');
	cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
	cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    double L;
    cin >> L;

    cout << fixed << setprecision(12);
    cout << (L/3.0)*(L/3.0)*(L/3.0) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ull = unsigned long long;
using namespace std;
const ull MAXN = 1e18;
int main() {
    int n; cin >> n;
    ull a[n] = {};
    for (int i = 0; i < n; i++)
        cin >> a[i];
    if (count(a, a + n, 0)) {
        cout << 0 << "\n";
        return 0;
    }
    ull ans = 1;
    for (int i = 0; i < n; i++) {
    	ull next = ans * a[i];
    	if (next / a[i] != ans or next > MAXN) {
            cout << -1 << "\n";
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int a;
  string s;
  cin >> a >> s;
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;

struct Pair{
    int idx, w;
};
bool operator<(Pair a, Pair b){
    return a.w < b.w;
}
Pair a[maxn];
int p[maxn], n, m, cnt[maxn], Min[maxn], Min_idx[maxn], del[maxn];
ll ans = 0;

int Find(int x){return p[x]==x?x:p[x]=Find(p[x]);}

int main()
{
//    freopen("e:\\in.txt", "r", stdin);
    memset(cnt, 0, sizeof(cnt));
    memset(del, 0, sizeof(del));
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i].w);
        a[i].idx = i;
        p[i] = i;
        Min[i] = 1e9 + 5;
    }
    for(int i = 0; i < m; i++){
        int u, v;
        scanf("%d%d", &u, &v);
        p[Find(v)] = Find(u);
    }
    if(n < 2*(n - m - 1)){
        cout<<"Impossible"<<endl;return 0;
    }
    if(m == n - 1){
        cout<<0<<endl;return 0;
    }
    for(int  i = 0; i < n; i++)Find(i);
    for(int i = 0; i < n; i++){
        if(a[i].w < Min[p[i]]){
            Min[p[i]] = a[i].w;
            Min_idx[p[i]] = i;
        }
        cnt[p[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(cnt[i] == 0)continue;
        ans += Min[i];
        del[Min_idx[i]] = 1;
    }
    sort(a, a + n);
    int ccnt = 0;
    for(int i = 0; i < n && ccnt < n - m - 2; i++){
        if(del[a[i].idx]){
            continue;
        }
        ccnt++;
        ans += a[i].w;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2944
N,a,b=map(int,input().split())
MOD=10**9+7
def comb(n,k):
  tmp=1
  for i in range(n-k+1,n+1):
    tmp*=i
    tmp%=MOD
  for i in range(1,k+1):
    tmp*=pow(i,MOD-2,MOD)
    tmp%=MOD
  return tmp
ans = pow(2,N,MOD) - 1 - comb(N,a) - comb(N,b)
print(ans%MOD)


Measured memory_bytes: 38768
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#include <cmath>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

double sankaku(double a, double b, double menseki) {
  double c = menseki * 2 / b;
  double ret = atan(b / c);
  ret = ret * 180 / M_PI;
  return ret;
}

double daikei(double a, double b, double menseki) {
  double c = menseki * 2 / a - b;
  double ret = atan((b-c) / a);
  ret = ret * 180 / M_PI;
  return ret;
}

void solve() {
  double a, b, x;
  cin >> a >> b >> x;

  double menseki = x / a;
  if (menseki > a * b / 2) {
    cout << daikei(a, b, menseki) << endl;
  } else {
    cout << sankaku(a, b, menseki) << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

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

const int SIZE = 100000 + 100;
ll data[SIZE][3];
ll dp[SIZE][3];

const ll INF = 1LL<<60;
int main() {
  int N, K; cin>>N;
  ll ans = 0;
  REP(i,N) {
    REP(j,3) {
      cin >> data[i][j];
    }
  }
  REP(i,3) dp[0][i] = data[0][i];
  for(int i = 1; i < N; i++) {
    REP(j, 3){
      REP(k, 3) {
        if(j == k) continue;
        dp[i][k] = max(dp[i][k], dp[i-1][j] + data[i][k]);
      }
    }
  }
  REP(i, 3) {
    ans = max(ans, dp[N-1][i]);
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

template<class T> inline void chmax(T &a, T b) {if(a < b) a = b;}

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

    int N,W;
    cin >> N >> W;
    ll w[110],v[110];
    for(int i=0;i<N;i++) cin >> w[i] >> v[i];
    ll dp[110][100100] = {0};
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            chmax(dp[i+1][j],dp[i][j]);
            if(j-w[i]>=0) chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 86272
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var ans = 0;
            for (int i = 0; i < n; i++)
            {
                var a = ReadInts();
                ans += a[1] - a[0] + 1;
            }
            WriteLine(ans);

        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 13140
#include<iostream>

using namespace std;

int N; //number of slimes 
int a[101]; // colors of the slimes 

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++)
		cin >> a[i];

	int res = 0;

	for (int i = 2; i <= N; i++) {
		if (a[i - 1] == a[i])
		{
			res++;
			a[i] = res + N;
		}
	}

	cout << res << endl;
	//cout << "Hello";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;

    vector<int> v(N);    
    map<int, int> a;
    map<int, int> b;

    for (int i = 0; i < N; i++) {
        cin >> v[i];
        if (i % 2 == 0) a[v[i]] += 1; 
        else b[v[i]] += 1; 
    }

    int a_1 = 0, b_1 = 0;
    int a_2 = 0, b_2 = 0;
    int a1 = 0, a2 = 0;
    int b1 = 0, b2 = 0;
    int cnt = 0;

    for (auto itr = a.begin(); itr != a.end(); itr++) {
        if (itr->second > cnt) {
            cnt = itr->second;
            a_1 = itr->first;
        }
    }

    a1 = cnt;
    cnt = 0;

    for (auto itr = a.begin(); itr != a.end(); itr++) {
        if (itr->second > cnt && itr->first != a_1) {
            cnt = itr->second;
            a_2 = itr->first;
        }
    }

    a2 = cnt;
    cnt = 0;

    for (auto itr = b.begin(); itr != b.end(); itr++) {
        if (itr->second > cnt) {
            cnt = itr->second;
            b_1 = itr->first;
        }
    }

    b1 = cnt;
    cnt = 0;

    for (auto itr = b.begin(); itr != b.end(); itr++) {
        if (itr->second > cnt && itr->first != b_1) {
            cnt = itr->second;
            b_2 = itr->first;
        }
    }

    b2 = cnt;

    if (a_1 == b_1) {
        cout << min(N-a1-b2, N-a2-b1) << endl;
    } else {
        cout << N-a1-b1 << endl;
    }

    return 0;
}

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

long long factorialMethod(long long k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=MOD;
    }
    return sum;
}

int main() {
    ll n,m;
    cin >> n >> m;
    if(abs(n-m) >= 2){
        cout << 0 << endl;
    }else if((n+m)%2 == 0){
        cout << (factorialMethod(n)* factorialMethod(m) * 2) %MOD << endl;
    }else{
        cout << (factorialMethod(n) * factorialMethod(m)) %MOD << endl;
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
import Control.Monad
import Data.List

main = do
  n <- readLn
  abs <- map (map read . words) <$> replicateM n getLine
  let [as,bs] = transpose abs
  print (marray 0 (reverse as) (reverse bs))

marray acc (a:as) (b:bs) = marray (acc + d) as bs
  where
    d = if r == 0 then 0 else b - r 
    r = mod (a+acc) b
marray acc _ _ = acc

Measured memory_bytes: 180604
h, w = gets.split.map(&:to_i)
n = gets.to_i
a = gets.split.map(&:to_i)

ans = []
a.each.with_index(1) do |x, i|
    ans += [i] * x
end

ans.each_slice(w).with_index do |ary, i|
    ary.reverse! if i.odd?
    puts ary.join(" ")
end

Measured memory_bytes: 67644
import sys
N = int(input())
A=[input() for i in range(N)]
M = int(input())
B=[input() for i in range(M)]
s = list(set(A) | set(B))
cnt = 0
for i in s:
  cnt = max(cnt,A.count(i)-B.count(i))
#  print(i,A.count(i),B.count(i),cnt)
print(max(0,cnt))

Measured memory_bytes: 3064
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
sum = 0
if N <= K:
    for i in range(0,N):
        sum = sum + X
if N >= K + 1:
    for i in range(0,K):
        sum = sum + X
    for i in range(K,N):
        sum = sum + Y
print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int D,N; cin>>D>>N;
    int ans;
    if(N<100)
        ans=pow(100,D)*N;
    if(N==100)
        ans=pow(100,D)*101;
    cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.*;
public class Main{
  public static void main(String args[]){
  Scanner sc = new Scanner(System.in);
  //int n = sc.nextInt();
  int a[] = new int[3];
  for(int i=0; i<a.length; i++){
  a[i] = sc.nextInt();
  }
  Arrays.sort(a);
  
  int a_last = a[a.length-1]*10;
  int a_last_1 = a_last+a[a.length-2];
  int a_last_2 = a_last_1+a[a.length-3];
  System.out.println(a_last_2);

  }
}

Measured memory_bytes: 21844
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    int ans=INF;
    int h,w;
    cin>>h>>w;
    int k;
    cin>>k;
    vector <string> s(h);
    rep(i,h)
    cin>>s[i];
    for (int mask=0;mask<(1<<(h-1));mask++)
    {
        int sum=__builtin_popcount(mask);
        vector <int> cur(sum+1);
        int summ=sum;
        vector <int> to(h);
        int curr=0;
        to[0]=0;
        bool ko=true;
        for (int i=0;i<h-1;i++)
        {
           if ((mask>>i)&1)
               to[i+1]=++curr;
           else
               to[i+1]=curr;
        }
        for (int j=0;j<w;j++)
        {
            for (int i=0;i<h;i++)
            {
                if (s[i][j]=='1') {
                    cur[to[i]]++;
                }
            }
            bool ok=false;
            for (int i=0;i<summ+1;i++)
            {
                if (cur[i]>k)
                    ok=true;
            }
            if (ok)
            {
                sum++;
                for (int i=0;i<summ+1;i++)
                    cur[i]=0;
                for (int i=0;i<h;i++)
                {
                    if (s[i][j]=='1') {
                        cur[to[i]]++;
                    }
                }
                for (int i=0;i<summ+1;i++)
                {
                    if (cur[i]>k)
                        ko=false;
                }

            }
        }
   //     cout<<sum<<" "<<mask<<'\n';
//        for (int i=0;i<summ+1;i++)
//            cout<<cur[i]<<'\n';
//        cout<<sum<<" "<<mask<<'\n';
//        for (int i=0;i<h;i++)
//            cout<<to[i]<<'\n';
        if (ko)
        ans=min(ans,sum);
    }

    cout<<ans;




}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
	long long I,O,T,J,L,S,Z;
	long long ans;
	cin >> I >> O >> T >> J >> L >> S >> Z ;
	
	if(I==0){
		ans = O + J/2*2 + L/2*2;
	}else if(J==0){
		ans = O + I/2*2 + L/2*2;
	}else if(L==0){
		ans = O + I/2*2 + J/2*2;
	}else if(I%2==1 && J%2==1 && L%2==1){
		ans = O + I/2*2 + J/2*2 + L/2*2 + 3;
	}
	else if(I%2==0 && J%2==1 && L%2==1){
		ans = O + (I/2-1)*2 + J/2*2 + L/2*2 + 3;
	}
	else if(I%2==1 && J%2==0 && L%2==1){
		ans = O + (J/2-1)*2 + I/2*2 + L/2*2 + 3;
	}else if(I%2==1 && J%2==1 && L%2==0){
		ans = O + (L/2-1)*2 + J/2*2 + I/2*2 + 3;
	}else{
		ans = O + I/2*2 + J/2*2 + L/2*2;
	}
	cout << ans << endl;
}
		

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

using namespace std;

typedef long long ll;

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

	ll h, n;
	cin >> h >> n;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll sm = 0;
	rep(i, n) sm += a[i];
	if(sm >= h){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
// #define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
 
const int N=2e5+1,OO=1e9;
int dir[228];
struct kek{
    int x,y,d;
}a[N];
void rot(int n){
    forn(i,n){
        int tx=a[i].x;
        int ty=a[i].y;
        a[i].x=ty;
        a[i].y=N-1-tx;
        (++a[i].d)&=3;
    }
}
vector<int> v[N+N],x[N];
int solve(int n){
    forn(i,N+N)v[i].clear();
    forn(i,N)x[i].clear();
    forn(i,n){
        if(a[i].d==1)v[a[i].x+a[i].y].pb(-a[i].x);
        if(a[i].d==2)x[a[i].x].pb(a[i].y);
    }
    forn(i,N+N)sort(v[i].begin(), v[i].end());
    forn(i,N)sort(x[i].begin(), x[i].end());
    int res=OO;
    forn(i,n){
        if(a[i].d==0){
            {
                auto it=lower_bound(x[a[i].x].begin(), x[a[i].x].end(),a[i].y);
                if(it!=x[a[i].x].end())upn(res,(*it-a[i].y)*5);
            }
            {
                int xy=a[i].x+a[i].y;
                auto it=lower_bound(v[xy].begin(), v[xy].end(),-a[i].x);
                if(it!=v[xy].end())upn(res,(a[i].x+*it)*10);
            }
        }
    }
    return res;
}
int32_t main(){
    dir['U']=0;dir['R']=1;
    dir['D']=2;dir['L']=3;
    int n;cin>>n;
    forn(i,n){
        char c;
        cin>>a[i].x>>a[i].y>>c;
        a[i].d=dir[c];
    }
    int ans=OO;
    forn(i,4){
        upn(ans,solve(n));
        rot(n);
    }
    if(ans==OO)cout<<"SAFE\n";
    else cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 32452
import math

n = int(input())
town = [list(map(int, input().split())) for _ in range(n)]

dist = 0
from itertools import permutations
for p in permutations(town):
    for i in range(n-1):
         dist += math.sqrt((p[i][0] - p[i+1][0]) **2 + (p[i][1] - p[i+1][1]) **2)
ans = dist / math.factorial(n)
print(ans)
"""
dist = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        dist += math.sqrt((town[i][0] - town[j][0]) **2 + (town[i][1] - town[j][1]) **2)
ans = dist / n
print(ans)
"""

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int dx[2] ={1,0};
const int dy[2] ={0,1};

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    queue<P> q;
    q.push({0,0});
    bool ok = false;
    vector<vector<bool>> che(h,vector<bool>(w,0));
    while(q.size()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        che[x][y] = true;
        if(x==h-1 && y==w-1){
            ok = true;
            break;
        }
        bool one = false,two = false;
        rep(i,2){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx<0 || nx>=h || ny<0 || ny>=w || s[nx][ny]=='.') continue;
            q.push({nx,ny});
            if(i==0) one = true;
            if(i==1) two = true;
        }
        if(one && two){
            ok = false;
            break;
        }
    }
    rep(i,h) rep(j,w) if(s[i][j] == '#' && !che[i][j]) ok = false;
    cout << (ok? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

void loadData(int *data,int *cData){
	for(int i=0;i<=9;i++){
		cData[i] = data[i];
	}
}

int main(){

	//dataが固定用。aData,bDataを変化させて行う。aDataは頭を固定しbDataにてへんか
	int data[9+1];
	int aData[9+1];
	int bData[9+1];
	int cData[9+1];
	int ansData[9+1];
	int ansState=0;
	int ansCnt = 0;
	int size = 0;
	char tmp;
	queue<int> ans;
	while(cin>>tmp){
		if(tmp=='0')break;
		int flag = 0;
		ansState = 0;
		ansCnt = 0;
		for(int i=0;i<=9;i++){
			data[i]=0;
			ansData[i]=0;
		}
		//データ入力
		data[tmp-'0']++;
		for(int i=1;i<13;i++){
			cin>>tmp;
			data[tmp-'0']++;
		}
		int head,sum;
		//なにを追加するのかのループ
		for(int i=1;i<=9;i++){
			head=0;
			sum = 0;
			loadData(data,aData);
			if(aData[i]==4){
				continue;
			}
			aData[i]++;
			//頭をまず考える。
			for(int j=1;j<=9;j++){
				head = 0;
				sum = 0;
				loadData(aData,bData);
				if(bData[j]-2>=0){
					//cout<<"head is "<<j<<endl;
					head++;
					bData[j]-=2;
				}
				for(int l=0;l<2;l++){
					sum = 0;
					if(l==0){
						loadData(bData,cData);
						//さらに階段状
						for(int k=1;k<=7;k++){
							if(cData[k] && cData[k+1] && cData[k+2]){
								cData[k]--;
								cData[k+1]--;
								cData[k+2]--;
								sum++;
								k=0;
							}
						}

						//その後3つあるものを考える。
						for(int k=1;k<=9;k++){
							if(cData[k]-3>=0){
								cData[k]-=3;
								sum++;
								//cout<<"triple,k = "<<k<<" sum = "<<sum<<endl;
							}
						}
					//	cout<<"i ="<<i<<"head = "<<head<<"sum = "<<sum<<endl;
						if(head==1 && sum == 4){
							ansData[i]++;
							ansCnt++;
						}
					}
					else{
						loadData(bData,cData);
						//その後3つあるものを考える。
						for(int k=1;k<=9;k++){
							if(cData[k]-3>=0){
								cData[k]-=3;
								sum++;
					//			cout<<"triple,k = "<<k<<" sum = "<<sum<<endl;
							}
						}
						//さらに階段状
						for(int k=1;k<=7;k++){
							if(cData[k] && cData[k+1] && cData[k+2]){
								cData[k]--;
								cData[k+1]--;
								cData[k+2]--;
								sum++;
								k=0;
							}
						}
					//	cout<<"i ="<<i<<"head = "<<head<<"sum = "<<sum<<endl;
						if(head==1 && sum == 4){
							ansData[i]++;
							ansCnt++;
						}
					}
				}
			}
		}
		/*
		for(int i=1;i<=9;i++){
			if(ansData[i]){
				ansState++;
				if(ansCnt>ansState+1){
					cout<<i<<" ";
				}
				else{
					cout<<i;
				}
			}
		}
		if(ansCnt==0){
			cout<<"0";
		}
		cout<<endl;
		*/

		if(ansCnt==0){
			ans.push(0);
			size++;
		}
		else{
			for(int x=1;x<=9;x++){
				if(ansData[x]){
					ans.push(x);
					size++;
				}
			}
		}
		ans.push(-1);
	}
	size = ans.size();
	for(int i=0;i<size;i++){
		if(ans.front()!=-1){
			cout<<ans.front();
			ans.pop();
			if(ans.front()!=-1){
				cout<<" ";
			}
		}
		else{
			cout<<endl;
			ans.pop();
		}
	}



	return 0;
}

/*
Sample Input
3649596966777
6358665788577
9118992346175
9643871425498
7755542764533
1133557799246
Output for the Sample Input
2 3 5 8
3 4
1 2 3 4 5 6 7 8 9
7 8 9
1 2 3 4 6 7 8
0
*/

Measured memory_bytes: 1180
'''
Created on 2020/08/17

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  A=list(map(int,pin().split()))
  A.sort()
  t=A[2]
  ans=0
  if A[0]%2!=A[1]%2:
    ans+=1
    A[1]+=1
    A[2]+=1
  ans+=A[2]-A[1]+(A[1]-A[0])//2
  print(ans)
  return 

main()

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

int N;
string C;
int main() {
    cin >> N >> C;
    int i = 0, j = N - 1;
    int cnt = 0;
    while(i < j) {
        while(i <= j && C[i] != 'W') i++;
        while(i <= j && C[j] != 'R') j--;
        if (i < j) {
            swap(C[i++], C[j--]);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3744
def dfs(n, lower):
    if n == N:
        return [[]]
    else:
        res = []
        for i in range(lower, M + 1):
            for p in dfs(n + 1, i):
                res.append([i] + p)
        return res


N, M, Q = map(int, input().split())
A, B, C, D = [], [], [], []
for _ in range(Q):
    a, b, c, d = map(int, input().split())
    A.append(a - 1)
    B.append(b - 1)
    C.append(c)
    D.append(d)
res = 0
for p in dfs(0, 1):
    cur = 0
    for a, b, c, d in zip(A, B, C, D):
        if p[b] - p[a] == c:
            cur += d
    res = max(res, cur)
print(res)

Measured memory_bytes: 140708
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  string S; cin >> S;
  int ans1 = 0;
  int ans2 = 0;
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0 && S[i] == '1') {
      ans1++;
    } else if (i % 2 == 0 && S[i] == '0') {
      ans2++;
    } else if (i % 2 == 1 && S[i] == '0') {
      ans1++;
    } else if (i % 2 == 1 && S[i] == '1') {
      ans2++;
    }
  }

  cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    vl vec(3);
    REP(i,3){
        cin>>vec[i];
    }
    int k;
    cin>>k;
    sort(all(vec));
    REP(i,k){
        vec[2]*=2;
    }
    ll ans=0;
    REP(i,3){
        ans+=vec[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;
	char c;
	char str[1024];
	string s;
	ll l;
	int nextInt(){
		scanf("%d", &n);
		return n;
	}
	ll nextLong(){
		scanf("%lld", &l);
		return l;
	}
	char nextChar(){
		scanf("%c", &c);
		return c;
	}
	string next(){
		scanf("%s", str);
		return string(str);
	}
	string nextLine(){
		getline(cin, s);
		return s;
	}
};
Input in;

int a[15], b[15];
ll dp[15][2500];

int main(){
	while(1){
		int m = in.nextInt();
		if(m == 0) break;

		rep(i, m) a[i] = in.nextInt(), b[i] = in.nextInt();
		rep(i, 15) rep(j, 2500) dp[i][j] = 0LL;

		dp[0][0] = 1LL;
		rep(i, m){
			for(int j = 0; j < 2500; j++){
				if(dp[i][j] == 0LL) continue;
				for(int k = j, l = 0; k < 2500 && l <= b[i]; k += a[i], l++){
					dp[i + 1][k] += dp[i][j];
				}
			}
		}
		// for(int i = 0; i < m + 1; i++){
		// 	for(int j = 0; j < 26; j++){
		// 		printf("%4lld", dp[i][j]);
		// 	}
		// 	printf("\n");
		// }

		int g = in.nextInt();
		rep(i, g){
			int n = in.nextInt();
			printf("%lld\n", dp[m][n]);
		}
	}
}

Measured memory_bytes: 1480
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}


int main()
{
  int N = 5;
  vector<int> a(5);
  rep(i, N) cin >> a[i];
  int ans = 0;
  int max_loss = 0;
  foreach(x, a){
    int t = (x + 9) / 10 * 10;
    ans += t;
    max_loss = max(max_loss, t - x);
  }
  ans -= max_loss;
  cout << ans << endl;
  return 0;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n; scan(n);
      std::vector<long> xs(n);
      for(long &x : xs) scan(x);
      LI ys(10001);
      ys[0] = 1;
      for(long i = 0; i < n; ++i) {
         for(long k = 10000; k >= xs[i]; --k) {
            ys[k] += ys[k-xs[i]];
         }
      }
      long res = 0;
      for(long i = 0; i < 10001; ++i) {
         if( i % 10 == 0 ) continue;
         if( ys[i] != 0 ) res = i;
      }
      printf("%ld\n", res);
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}



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

int main(){
	long long int n,k,c=0,ans=0;
	cin>>n>>k;
	vector<int>a(200000);
	vector<int>b(200000);
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[a[i]-1]++;
	}
	sort(b.begin(),b.end(),greater<>());
	for(int i=0;b[i]!=0;i++){
		c=i;
	}
	for(int i=c;i>k-1;i--){
		ans+=b[i];
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int A,B,C,D,E,F;
	cin>>A>>B>>C>>D>>E>>F;
	double maxe=(double)100*E/(E+100);
	int swater=0,sugar=0;
	double nowe=0.0;
	rep(i,31){
		int tmpA=A*100*i;
		if(tmpA>F) break;
		rep(j,31){
			int tmpB=B*100*j;
			if(i==0 && j==0) continue;
			if(tmpA+tmpB>F) break;
			rep(k,3001){
				int tmpC=C*k;
				rep(l,3001){
					int tmpD=D*l;
					int tmpwater=tmpA+tmpB;
					int tmpsugar=tmpC+tmpD;
					double tmpe=(double)100*tmpsugar/(tmpwater+tmpsugar);
					if(tmpwater+tmpsugar>F) break;
					else if(tmpe>maxe) break;
					else if(tmpe>=nowe){
						swater = tmpwater+tmpsugar;
						sugar = tmpsugar;
						nowe = tmpe;
					}
				}
			}
		}
	}
	cout << swater << " " << sugar << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> A(M),B(M);
  vector<ll> parent(N+1,-2);
  vector<ll> ans(M,0);
  ans[M-1]=N*(N-1)/2;
  vector<ll> size(M);
  vector<ll> rank(M);
  FORi(M){
    cin>>A[i]>>B[i];
  }
  for(int i = M-1;i>=1;--i){
    if(parent[A[i]]==-2&&parent[B[i]]==-2){
      parent[A[i]]=-1;
      size[A[i]]=2;
      rank[A[i]]=2;
      parent[B[i]]=A[i];
      ans[i-1]=ans[i]-1;
    }else if(parent[A[i]]==-2&&parent[B[i]]!=-2){
      parent[A[i]]=B[i];
      ll curb=B[i];
      while(true){
        if(parent[curb]!=-1){
          curb=parent[curb];
        }else{
          break;
        }
      }
      ans[i-1]=ans[i]-size[curb];
      size[curb]++;
      rank[curb]++;
      
      ll r = curb;
      curb=B[i];
      ll precurb;
      while(true){
        if(parent[curb]!=-1){
          precurb=curb;
          curb=parent[curb];
          parent[precurb]=r;
        }else{
          break;
        }
      }
    }else if(parent[A[i]]!=-2&&parent[B[i]]==-2){
      parent[B[i]]=A[i];
      ll cura=A[i];
      while(true){
        if(parent[cura]!=-1){
          cura=parent[cura];
        }else{
          break;
        }
      }
      ans[i-1]=ans[i]-size[cura];
      size[cura]++;
      rank[cura]++;
      
      
      ll r = cura;
      cura=A[i];
      ll precura;
      while(true){
        if(parent[cura]!=-1){
          precura=cura;
          cura=parent[cura];
          parent[precura]=r;
        }else{
          break;
        }
      }
    }else{
      ll cura=A[i],curb=B[i];
      while(true){
        if(parent[cura]!=-1){
          cura=parent[cura];
        }else{
          break;
        }
      }
      while(true){
        if(parent[curb]!=-1){
         //cout<<"_" <<curb<<endl;
          curb=parent[curb];
        }else{
          break;
        }
      }
      if(cura!=curb){
        ans[i-1]=ans[i]-size[cura]*size[curb];
        if(rank[cura]>rank[curb]){
          parent[curb]=cura;
          size[cura]+=size[curb];
          rank[cura]=max(rank[cura],rank[curb]+1);
        }else{
          parent[cura]=curb;
          size[curb]+=size[cura];
          rank[curb]=max(rank[curb],rank[cura]+1);
        }
        //root.erase(rootcurb));
      }else{
        ans[i-1]=ans[i];
      }
    }
  }
  FORi(M){
   cout<<ans[i]<<endl; 
  }
  return 0;
}


Measured memory_bytes: 6016
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		if (A % 1000 == 0) {
			System.out.println(0);
		} else {
			System.out.println(1000 - (A % 1000));

		}
	}
}

Measured memory_bytes: 35732
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;

int main()
{
	int n;
	cin>>n;
	vector<ll> L(87);
	L[0] = 2;
	L[1] = 1;
	for(int i = 2; i <= n; i++){
		L[i] = L[i-1] + L[i-2];
	}
	cout<<L[n]<<endl;
	return 0;
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll a,b,c;
  cin>>a>>b>>c;
  if(c>=a)
  {
    cout<<0<<" ";
    c-=a;
    if(c>=b)
    {
      cout<<0<<endl;
    }
    else cout<<b-c<<endl;
  }
  else 
  {
    cout<<a-c<<" "<<b<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x, t;
  cin >> n >> x >> t;

  int time = n / x;

  if (n % x != 0) {
    time += 1;
  }
  int ans = t * time;

  cout << ans << endl;
}

Measured memory_bytes: 3580
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

const int LIM = 102030;
int isprime[LIM];

int N;

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

    fill(isprime, isprime+LIM, 1);
    isprime[0] = isprime[1] = false;
    for (int d = 2; d * d < LIM; ++d) {
        if (isprime[d]) {
            for (int y = d * d; y < LIM; y += d) {
                isprime[y] = 0;
            }
        }
    }

    cin >> N;
    for (int i = N; i < LIM; ++i) {
        if (isprime[i]) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 640