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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n],i;
	for(i=1;i<=n;i++){
		cin>>arr[i];
	}
	int dp[n+1]={0};
	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]);
	for(int j=3;j<=n;j++){
		dp[j]=min(abs(arr[j]-arr[j-1])+dp[j-1],abs(arr[j]-arr[j-2])+dp[j-2]);
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 int main() {
	string N;
   cin>>N;
   if(N[0]==N[2]){cout << "Yes" << endl;}
	else{ cout << "No" << endl;

   }
	}

Measured memory_bytes: 256
[N,M,Q] = list(map(int,input().split()))

abcd = []
for i in range(Q):
    abcd.append(list(map(int,input().split())))

from itertools import permutations, combinations,combinations_with_replacement,product
AA=range(1,M+1)
CM = list(combinations_with_replacement(AA,N))
#print(CM)
wa = 0
A = [0]*N
dammy=[]
for i in range(len(CM)):
    A = CM[i]
    for j in range(Q):
        #print(abcd[2][j])
        if (A[abcd[j][1]-1] - A[abcd[j][0]-1]) == abcd[j][2]:
            wa+=abcd[j][3]
    dammy.append(wa)
    wa =0

print(max(dammy))

Measured memory_bytes: 85920
#include <iostream>
#include <vector>
#define ll long long int

using namespace std;

struct Item {
	ll weight;
	ll value;
};

const ll INF = 1LL << 32;
vector<ll> dp(100001, INF);

ll knapSack(ll W, Item items[], ll n){
	ll sum = dp[0] = 0;
	for(ll i = 0; i < n; i++){
		sum += items[i].value;
    	for(ll j = sum; j >= items[i].value; j--){
         	dp[j] = min(dp[j], dp[j - items[i].value] + items[i].weight);
    	}
	}
	
	for(ll i = sum; i >= 0; i--){
		if(dp[i] <= W){
			return i;
		}
	}
}

int main(){
	Item items[100];
	ll N, W;
	cin >> N >> W;
	for(ll i = 0; i < N; i++)
		cin >> items[i].weight >> items[i].value;
	cout << knapSack(W, items, N) << endl;
	return 0;
}

Measured memory_bytes: 1024
s = input()
N = len(s)
res = N
for i in range(26):
    j = 0
    t = 0
    while j < N:
        cnt = 0
        while j < N and s[j] == chr(i + ord('a')):
            j += 1
        while j < N and s[j] != chr(i + ord('a')):
            cnt += 1
            j += 1
        t = max(t, cnt)
    res = min(res, t)
print(res)


Measured memory_bytes: 9036
// AOJ 0646 LthKthNumber
// 2018.4.16 bal4u

#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

long long llin()
{
	long long n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int N, K;
int a[200002];

long long calc(x)
{
	int i, j, s;
	long long ans;

	ans = 0, j = s = 0;
	for (i = 0; i < N; i++) {
		while (j < N && s < K) {
			if (a[j] < x) s++;
			j++;
		}
		if (s == K) ans += N-j+1;
		if (a[i] < x) s--;
	}
	return ans;
}

int main()
{
	int i;
	long long L;
	int lo, hi, mi;

	N = in(), K = in(), L = llin()-1;
	for (i = 0; i < N; i++) a[i] = in();

	lo = 0, hi = N+1;
	while (lo + 1 < hi) {
		mi = (lo + hi) >> 1;
		if (calc(mi) > L) hi = mi; else lo = mi;
	}
	printf("%d\n", lo);
	return 0;
}



Measured memory_bytes: 2480
package main

import "fmt"

func main() {
	var l, r int
	fmt.Scan(&l, &r)

	min := 2019
	for i := l; i < r; i++ {
		for j := l+1; j <= r; j++ {
			mod := i *j % 2019
			if min > mod {
				min = mod
				if min == 0 {
					fmt.Println(min)
					return	
				}
			}
		}

	}
	fmt.Println(min)
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int[] n = new int[4];
        int[] Ans = {1, 4, 7, 9};
        for (int i = 0; i < 4; i++) {
            n[i] = sc.nextInt();
        }

        Arrays.sort(n);
        boolean isAns = true;
        
        for (int i = 0; i < 4; i++) {
            if (n[i] != Ans[i])
                isAns = false;
        }
        
        System.out.println(isAns ? "YES" : "NO");
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

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

  int count = 0;
  while (true) {
    bool flag = true;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 == 0) {
        A[i] /= 2;
      } else {
        flag = false;
      }
    }
    if (flag) {
      count++;
    } else {
      break;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
n = gets.to_i
ary = 2.times.map{ gets.split.map(&:to_i)}
max = 0

n.times do |x|
  sum  = ary[0][0..x].inject(:+)
  sum += ary[1][x..-1].inject(:+)
  max = [max, sum].max
end

puts max


Measured memory_bytes: 1788
//I read the news today, oh boy
//About a lucky man who made the grade
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1e6;

ll a[N], acum[N];

int main(){
	fastio;
	int n; cin>>n;
	For(i,1,n+1) cin>>a[i];
	For(i,1,n+1) acum[i]=acum[i-1]+a[i];
	ll best = 1e18;
	For(i,2,n-1){
		ll lo = 1, hi = i;
		while(lo+1<hi){
			ll mid = (lo+hi)>>1;
			if(2*acum[mid]<=acum[i]) lo = mid;
			else hi = mid;
		}
		if(lo+1<i && acum[lo+1]<(acum[i]-acum[lo])) lo++;
		ll j = lo;
		lo = i+1, hi=n;
		while(lo+1<hi){
			ll mid = (lo+hi)>>1;
			if(2*acum[mid]<=(acum[n]+acum[i])) lo=mid;
			else hi = mid;
		}
		if(lo+1<n && (acum[lo+1]-acum[i]-(acum[n]-acum[lo+1]))<(acum[n]-acum[lo]-(acum[lo]-acum[i]))) lo++;
		ll k = lo;
		ll men = 1e18;
		ll may = 0;
		men = min(min(acum[j],acum[i]-acum[j]),min(acum[k]-acum[i],acum[n]-acum[k]));
		may = max(max(acum[j],acum[i]-acum[j]),max(acum[k]-acum[i],acum[n]-acum[k]));
		best = min(best,may-men);
	}
	cout << best << endl;
	return 0;
}



Measured memory_bytes: 6780
def k(a,i1,i2):
  if(a==7):
    i1 = i1+1
  if(a==5):
    i2 = i2+1
  return i1,i2
  
a,b,c=map(int,input().split())
i1=0
i2=0
i1,i2 = k(a,i1,i2)
i1,i2 = k(b,i1,i2)
i1,i2 = k(c,i1,i2)
print('YES' if i1==1 and i2==2 else 'NO')

Measured memory_bytes: 3064
#ifdef __unix__
#include <bits/stdc++.h>
#else
#include <iostream>
#include <algorithm>
#include <math.h>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#endif


#define fastIO ios_base::sync_with_stdio(0), cin.tie(NULL)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
#define mkp make_pair
/*#define NUMTOSTR(x)  (unsigned char)((x) + 48);*/
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long  ull;
using namespace std;
int main(){
	int inner;
	int n;
	int k;
	cin >> n >> k;
	if (n > 10) {
		cout << k;
		return 0;
	}
	else inner = k + 100 * (10 - n);
	cout << inner;
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 20
#define EPS 1e-9

struct Point{
  double x, y;
}; 

int N;
Point h, d, crystal[MAX];
 
double dist(Point a, Point b){
  return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}

bool used[MAX];
bool rec(int now, double total_dist, int depth){
  if(depth == N){
    return true;
  }

  for(int i = 0 ; i < N ; i++){
    if(!used[i]){
      if(total_dist + dist(crystal[now],crystal[i]) >= dist(d,crystal[i])){
        return false;
      }
    }
  }

  for(int i = 0 ; i < N ; i++){
    if(!used[i]){
      used[i] = true;
      if(rec(i, total_dist + dist(crystal[now],crystal[i]), depth+1)){
        return true;
      }
      used[i] = false;
    }
  }
  return false;
}

bool solve(){
  for(int i = 0 ; i < N ; i++){
    memset(used, false, sizeof(used));
    if(rec(i, dist(h, crystal[i]), 0)){
      return true;
    }
  }

  return false;
}
 
int main(){
  while(cin >> N >> h.x >> h.y >> d.x >> d.y, (N + h.x + h.y + d.x + d.y)){
    for(int i = 0 ; i < N ; i++){
      cin >> crystal[i].x >> crystal[i].y;
    }
    cout << (solve() ? "YES" : "NO") << endl;
  }
  
  return 0;
}

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

int main()
{
	int H, W;
	
	while(scanf("%d %d", &H, &W))
	{
		bool ok = true , go = false;

		if(H == 0 && H ==W)
		{
			break;
		}
		
		for(int i = 0;i < H;i++)
		{
			if(ok)
			{
				go = true;
				for(int j = 0; j < W; j++)
				{					
					if(go)
					{
						printf("#");
						go = false;
					}
					else
					{
						printf(".");
						go = true;						
					}					
				}
				printf("\n");
				ok = false;			
			}
			else
			{
				go = true;
				for(int j = 0; j < W; j++)
				{
					if(go)
					{
						printf(".");
						go = false;
					}
					else
					{
						printf("#");
						go = true;
					}					
				}
				printf("\n");
				ok = true;
			}	
		}		
		printf("\n");
		ok = true;
		go = false;	
	}            	
	return 0;
}


Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		ans+=n/i;
		if(n%i==0)
		{
			ans--;
		}
	}
	printf("%d",ans);
	return 0;
}

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

int main()
{
	int n = 0;
	scanf("%d", &n);
	int* a = (int *)malloc(sizeof(int) * n);
	int ch,k=0;

	while(scanf("%d", &ch) != EOF){
		a[k] = ch;
		k++;
	}

	int flag = 1;
	int change_count = 0;
	while(flag){
		flag = 0;
		for (int j = n-1; j > 0; j--)
		{
			if(a[j] < a[j-1])
			{
				int tmp = a[j];
				a[j] = a[j-1];
				a[j-1] = tmp;
				flag = 1;
				change_count ++;
			}
		}
	}

	for(int j = 0; j < n; j++){
		printf("%d", a[j]);
		if(j != n-1) printf(" ");
	}
	printf("\n");
	printf("%d\n", change_count);
	return 0;
}


Measured memory_bytes: 1968
def coin(n, p, c):
    global count
    global m
    if n % c[0] == 0:
        count = min(count, p + n // c[0])
        return count
    elif p + n // c[0] >= count:
        return n
    elif c[0] < n:
        return min(coin(n - c[0], p + 1, c), coin(n, p, c[1:]))
    else:
        return coin(n, p, c[1:])

n, m = map(int, input().split())

mon = list(map(int, input().split()))

mon.sort(reverse = True)

count = n

print(coin(n, 0, mon))


Measured memory_bytes: 5604
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int i, j;
	int N, X;
	int m[1001];
	int sum = 0;
	int minm = 1000;
	int count = 0;

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

	for (i = 0; i < N; ++i) {
		sum += m[i];
		minm = min(minm, m[i]);
	}

	while (sum <= X) {
		sum += minm;
		++count;

	}
	cout << count + N-1 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  int ans=0;
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(i!=minj){
      swap(A[i],A[minj]);
      ans++;
    }
  }
  for(int i=0;i<n;i++) cout<<A[i]<<" \n"[i==n-1];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
}

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

int main() {
	string A, B, C;
	int N, i, count = 0;
	cin >> N >> A >> B >> C;
	for (i = 0;i < N;i++) {
		if (A[i] == B[i] && B[i] != C[i]) {
			count++;
		}
		else if (A[i] != B[i] && B[i] == C[i]) {
			count++;
		}
		else if (A[i] == C[i] && B[i] != C[i]) {
			count++;
		}
		else if (A[i] != B[i] && B[i] != C[i]) {
			count = count + 2;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
/*
 * src.cpp
 *
 *  Created on: 2016/10/01
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=2e5;

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

int N;
P A[MAX_N];
ll dp[MAX_N];

set<int> s1,s2;

int main(){
	scanf("%d",&N);
	REP(i,N){
		int a;
		scanf("%d",&a);
		A[i]=P(a,i);
	}
	sort(A,A+N);
	ll res=0;
	REP(i,N){
		int ub,lb;
		set<int>::iterator ite;
		ite=s1.upper_bound(A[i].second);
		if (ite==s1.end()){
			ub=N;
		}else{
			ub=*ite;
		}
		ite=s2.upper_bound(-A[i].second);
		if (ite==s2.end()){
			lb=-1;
		}else{
			lb=-*ite;
		}
		res+=(ll)(A[i].second-lb)*(ub-A[i].second)*A[i].first;
		s1.insert(A[i].second);
		s2.insert(-A[i].second);
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 20608
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
char s[maxn];
int dp[2][2020];
void solve(){
	int len = strlen(s+1);
	ll ans = 0;
	for(int i = 1;i <= len;i++){
		int x = s[i] - '0';
		rep(j,0,2019) dp[(i&1)][j] = 0;
		dp[(i & 1)][x%2019]++;
		for(int j = 0;j < 2019;j++)
			dp[(i & 1)][(x+j*10)%2019] += dp[(i & 1) ^ 1][j];
		ans += 1LL*dp[(i & 1)][0];
	}
	cout << ans << endl;
	return;
}
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	scanf("%s",s+1);
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 3964
class Dice:
    def __init__(self, top, front, right, left, rear, bottom):
        self.top = top
        self.front = front
        self.right = right
        self.left = left
        self.rear = rear
        self.bottom = bottom
    def print(self):
        '''print top of dice'''
        print(self.top)
    def north(self):
        self.top, self.front, self.bottom, self.rear = \
            self.front, self.bottom, self.rear, self.top
    def south(self):
        self.top, self.front, self.bottom, self.rear = \
            self.rear, self.top, self.front, self.bottom
    def east(self):
        self.top, self.right, self.bottom, self.left = \
            self.left, self.top, self.right, self.bottom
    def west(self):
        self.top, self.right, self.bottom, self.left = \
            self.right, self.bottom, self.left, self.top
    def find_right(self, top, front):
        if top == self.top:
            pass
        elif top == self.front:
            self.north()
        elif top == self.rear:
            self.south()
        elif top == self.right:
            self.west()
        elif top == self.left:
            self.east()
        elif top == self.bottom:
            self.north()
            self.north()
        else:
            return -1
        if front == self.front:
            return self.right
        elif front == self.right:
            return self.rear
        elif front == self.rear:
            return self.left
        elif front == self.left:
            return self.front
        else:
            return -1

d = list(map(int, input().split()))
dice = Dice(d[0], d[1], d[2], d[3], d[4], d[5])
q = int(input())

for i in range(q):
    top, front = map(int, input().split())
    right = dice.find_right(top, front)
    print(right)



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k,i,c;
    cin>>k;
    if(k%2==0 || k%5==0)
    {
    	cout<<"-1\n";
    }
    else
    {
    	c=0;
    	for(i=0; ;i++)
    	{
    		c=(c*10+7);
    		if(c%k==0)
    		{
    			break;
    		}
    		c=c%k;
    	}
    	cout<<i+1<<"\n";
    }
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <cstdio>
#include <cmath>

using namespace std;

string str_week[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "All" };
map<string, int> W;
int s, n, t, p, m;
string week, sTime;

// 時間を進める(分単位)
void addTime ( int &hh, int &mm, int &ww, int x )
{
	static const int day = 24 * 60 * 60;
	static const int hou = 60 * 60;
	static const int min = 60;
	if (!x) { return; }
	int tt = hh * hou + mm * min + x * min;
	if (tt >= day) {
		ww <<= 1;
		tt %= day;
		if (ww >= (1 << 7)) { ww = 1; }
	}
	hh = tt / hou;
	tt %= hou;
	mm = tt / min;
}

// 突然変異可能な曜日・時間帯か調べる
bool isChange ( int hh, int mm, int ww )
{
	if ((W[week] & ww) == 0) { return false; }
	if (sTime == "All") { return true; }
	if (sTime == "Day" && (6 <= hh && hh < 18)) { return true; }
	if (sTime == "Night" && (18 <= hh || hh < 6)) { return true; }
	return false;
}

// 確率をシミュレーションする
double getProb ( int hh, int mm, int ww )
{
	double miss = 1.0, prob = pow((p - 1.0)/ (double)p, n);
	for (int i = 0; i < m; ++i) {
		bool hit = true;
		hit &= isChange(hh, mm, ww); // 卵の出現した時は変異の範囲内か
		addTime(hh, mm, ww, s);
		hit &= isChange(hh, mm, ww); // 孵化の時は変異の範囲内か
		if (hit) { // 出現から孵化まで変異の範囲内なので変化が起こる(失敗)
			miss *= prob;
		}
		addTime(hh, mm, ww, t - s); // ステージの終了まで時間を進める
	}
	return 1.0 - miss;
}

int main ( void )
{
	W["All"] = (1 << 7) - 1;
	for (int i = 0; i < 7; ++i) {
		W[str_week[i]] = 1 << i;
	}
	while (cin >> s >> n >> t >> week >> sTime >> p >> m) {
		if (s+n+t+p+m == 0 && week == sTime && week == "None") { break; }
		double ans = 0;
		for (int i = 0; i < 7; ++i) {
			for (int j = 0; j < 24; ++j) {
				for (int k = 0; k < 60; ++k) {
					ans = max(ans, getProb(j, k, W[str_week[i]]));
				}
			}
		}
		printf("%.10lf\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1280
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(r,e){function t(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){var e=t(r.split("\n")[0].split(" ").map(function(r){return Number(r)}),2),n=e[0],o=e[1],u={1:o};u[o]=1;for(var i=Math.sqrt(o),f=2;f<i+1;f++)if(o%f==0){u[f]=0;for(var l=o;l>0&&l%f==0;)l/=f,u[f]+=1}var a=1;for(var c in u)u[c]>=n&&Number(c)>a&&(a=Number(c));console.log(a)}},function(r,e){r.exports=require("fs")}]);

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


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int products, coupons;
    
    cin >> products >> coupons;
    
    priority_queue<long int> prices;
    for(int i = 0; i < products; i++){
        int tmp;
        cin >> tmp;
        prices.push(tmp);
    }
    
    for(int i = 0; i < coupons; i++){
        int tmp = prices.top();
        prices.pop();
        prices.push(tmp / 2);
    }
    
    unsigned long long int total = 0;
    for(int i = 0; i < products; i++){
        total += prices.top();
        prices.pop();
    }
    cout << total;
    
	return 0;
}


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


public class Main {

	Scanner sc;
	
	class Vector{
		public double x, y;
		
		public Vector(double x, double y){
			this.x=x;
			this.y=y;
		}
		
		public double norm(){
			return Math.hypot(x, y);
		}
		
		public double sqrNorm(){
			return x*x+y*y;
		}
		
		public double ip(Vector v){
			return x*v.x+y*v.y;
		}
		
		public Vector add(Vector v){
			return new Vector(x+v.x, y+v.y);
		}
		
		public Vector subtract(Vector v){
			return new Vector(x-v.x, y-v.y);
		}
		
		public Vector multiply(double a){
			return new Vector(x*a, y*a);
		}
		
		public String toString(){
			return String.format("(%f,%f)", x, y);
		}
	}
	
	boolean inTriangle(Vector[] v){
		double theta=0;
		for(int i=0;i<3;++i){
			theta+=Math.acos(v[i].ip(v[(i+1)%3])/v[i].norm()/v[(i+1)%3].norm());
		}
		return theta>=Math.PI*2-1e-7;
	}
	
	char solve(Vector[] a, Vector p, double r){
		Vector[] v=new Vector[3], e=new Vector[3];
		r*=r;
		
		boolean isB=true;
		for(int i=0;i<3;++i){
			v[i]=a[i].subtract(p);
			e[i]=a[(i+1)%3].subtract(a[i]);
			isB&=v[i].sqrNorm()<=r;
		}
		if(isB) return 'b';
		
		Vector[] h=new Vector[3];
		boolean isA=true;
		for(int i=0;i<3;++i){
			//円の中心より三角形の辺と直交するvector
			//hi=vi+(ei・(-vi)/|ei|^2)ei
			h[i]=v[i].subtract(e[i].multiply(e[i].ip(v[i])/e[i].sqrNorm()));
			isA&=h[i].sqrNorm()>=r;
		}
		if(isA&&inTriangle(v)) return 'a';
		
		//円の半径以内に三角形の辺∨頂点が存在?
		boolean isC=false;
		for(int i=0;i<3;++i){
			//n: 三角形の辺を延長した直線と, それに直交する円の中心からの直線の交点
			Vector n=h[i].add(p);
			if(v[i].sqrNorm()<=r||(n.subtract(a[i]).ip(n.subtract(a[(i+1)%3]))<=0&&h[i].sqrNorm()<=r)){
				isC=true;
			}
		}
		if(isC) return 'c';
		else return 'd';
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	void io(){
		sc=new Scanner(System.in);
		
		while(true){
			int x=ni(),y=ni();
			if(x==0&y==0)break;
			
			Vector[] a=new Vector[3];
			
			for(int i=0;i<3;++i){
				a[i]=new Vector(x, y);
				x=ni(); y=ni();
			}
			Vector p=new Vector(x, y);
			double r=ni();
			
			System.out.println(solve(a,p,r));
		}
	}
	
	void debug(Object...os){
		System.err.println(Arrays.deepToString(os));
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

Measured memory_bytes: 21124
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
ll mod = 1e9+7;

int main() 
{ 
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0; i<n; i++) cin>>a[i];
	sort(a,a+n);
	int sum=0;
	for(int i=0; i<k; i++)
		sum+= a[i];
	cout<<sum;

    return 0; 
} 

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define sachin ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    sachin
    long long n;
    cin>>n;
    vector <long long> vect(n+1,0);
    for(int i=1;i<=n;i++)cin>>vect[i];
    for(int i=n;i>1;i--)
    {
        if(vect[i]>=vect[i-1])
            continue;
        else if(vect[i]+1==vect[i-1])
            vect[i-1]--;
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int main(void){
	int n,a,i,color[110]={0},max=8,m=0;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(a<400){
			color[0]++;
		}else if(a<800){
			color[1]++;
		}else if(a<1200){
			color[2]++;
		}else if(a<1600){
			color[3]++;
		}else if(a<2000){
			color[4]++;
		}else if(a<2400){
			color[5]++;
		}else if(a<2800){
			color[6]++;
		}else if(a<3200){
			color[7]++;
		}else{
			color[max]++;
			max++;
			m++;
		}
	}
	
	int sum = 0;
	for(i=0;i<8;i++){if(color[i] != 0)sum++;
	}
	if(n==m)printf("1");
	else	printf("%d",sum);
	for(i=8;i<110;i++){if(color[i] != 0)sum++;
	}
	printf(" %d",sum);
	
	
	return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
  ll A;
  double B;
  cin >> A >> B;
  int c = (int)(B * 100 + 0.1);
  cout << A * c / 100 << endl;
  return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int k,s,n;
	int buf;
	cin>>k>>s>>n;
	

	if(k>s){
		buf = k;
		k = s;
		s = buf;
		
	}
	if(s>n){
		
		buf = s;
		s = n;
		n = buf;
	}
	if(k>s){
		buf = k;
		k = s;
		s = buf;
		
	}
	printf("%d %d %d\n",k,s,n);
}

Measured memory_bytes: 3156
#include<stdio.h>

int main(void)
{
   int n, t, a, h[1000], i, f=1;
   double s, x;

   scanf("%d%d%d",&n,&t,&a);
   for(i=0;i<n;i++)
      scanf("%d",&h[i]);

   x=t-(double)h[0]*0.006;
   if(a>x)
      s=a-x;
   else
      s=x-a;
   for(i=1;i<n;i++){
      x=t-(double)h[i]*0.006;
      if(a>x){
         if(a-x<s){
            s=a-x;
            f=i+1;
         }
      }
      else
         if(x-a<s){
            s=x-a;
            f=i+1;
         }
   }

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

Measured memory_bytes: 128
#!/usr/bin/env python3
#ABC66 C

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

front = []
back = []

for i in range(n):
    if i % 2 == 0:
        front.append(a[i])
    else:
        back.append(a[i])
if n % 2 == 1:
    front = front[::-1]
    ans = front+back
    print(' '.join(map(str,ans)))
else:
    back = back[::-1]
    ans = back+front
    print(' '.join(map(str,ans)))


Measured memory_bytes: 32192
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N = 0, M = 0;
    cin >> N >> M;
    vector<long long> a(M);
    for (int i = 0; i < M; i++) {
        cin >> a.at(i);
    }
    vector<int> onoff(N + 1);
    for (int i = 0; i < N + 1; i++) {
        onoff.at(i) = 1;
    }
    for (int i = 0; i < M; i++) {
        onoff.at(a.at(i)) = 0;
    }
    vector<long long> howtogo(N + 1);
    howtogo.at(0) = 1;
    howtogo.at(1) = 1;
    if (N == 1) {
            cout << 1 << endl;
        }
        else {
            for (int i = 2; i <= N; i++) {
                howtogo.at(i) = ((howtogo.at(i-1) * onoff.at(i-1)) + (howtogo.at(i-2) * onoff.at(i-2))) % 1000000007;
                }
                cout << howtogo.at(N) % 1000000007 << endl;
        }
}

Measured memory_bytes: 2176
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    l='CODEFESTIVAL2016'
    s=str(input())
    ls=len(s)
    cnt=0
    for i in range(ls):
        if s[i]!=l[i]: cnt+=1
    print(cnt)
    
resolve()

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

n = int(input())
t = 0
x = 0
y = 0
judge = True

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

for t1, x1, y1 in l:
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        print("No")
        exit()
    x = x1
    y = y1
    t = t1

print("Yes")

Measured memory_bytes: 17312
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

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

  ll A,B,C,X,Y; cin>>A>>B>>C>>X>>Y;

  ll res = 10000000000;
  for(ll i=0; i<=max(X,Y); ++i) {     // i: ABの枚数*2
    ll a = max(X-i, 0LL);              // 必要なAの枚数
    ll b = max(Y-i, 0LL);              // 必要なBの枚数

    ll sum = A*a + B*b + C*(2*i);

    res = min(res, sum);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int d[101] = {0}, in;

	while(cin >> in)
		d[in]++;
	
	int res = 0;
	vint nums;

	REP(i, 1, 101)
	{
		if(res < d[i])
		{
			nums.clear();
			nums.push_back(i);
			res = d[i];
		}
		else if(res == d[i])
			nums.push_back(i);
	}

	rep(i, nums.size())
		cout << nums[i] << endl;
}

Measured memory_bytes: 0
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def integer_factorization(n):
    prime_count = collections.Counter()
    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n //= i
            prime_count[i] += 1
    if n > 1:
        prime_count[n] += 1
    return prime_count

def main():
    a, b = LI()
    d1 = integer_factorization(a)
    d2 = integer_factorization(b)
    dk1 = [k for k, v in d1.items()]
    dk2 = [k for k, v in d2.items()]
    ans = set()
    for a in dk1:
        if d2[a] == 0:
            continue
        ans.add(a)

    for b in dk2:
        if d1[b] == 0:
            continue
        ans.add(b)

    print(1 + len(ans))


main()



Measured memory_bytes: 83668
import java.util.*

val scanner = Scanner(System.`in`)

fun main(args: Array<String>) {
    val a = scanner.nextInt()
    val b = scanner.nextInt()
    val c = scanner.nextInt()
    val d = scanner.nextInt()

    val direct = Math.abs(a - c) <= d
    val indirect = Math.abs(a - b) <= d && Math.abs(b - c) <= d

    println(if (direct || indirect) "Yes" else "No")
}

Measured memory_bytes: 29608
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 

using namespace std;

struct Switch
{
	int blubs[10];
	int szBlub;
	int state;	//0--off, 1--on
};

Switch k[10];

int curState[10];
int p[10];
int n, m;
int numCount;

bool doCheck()
{
	for (int i = 1 ; i <= m ; i++)
		if (curState[i] != p[i])
			return false;
			
	return true;
}

void doSearch(int d)
{
	if (d > n)
	{
		if (doCheck())
			numCount++;
		
	}
	else
	{
		doSearch(d + 1);
		
		for (int j = 0 ; j < k[d].szBlub ; j++)
		{
			if (curState[k[d].blubs[j]] == 1)
				curState[k[d].blubs[j]] = 0;
			else
				curState[k[d].blubs[j]] = 1;
		}
		
		doSearch(d + 1);
		
		
		for (int j = 0 ; j < k[d].szBlub ; j++)
		{
			if (curState[k[d].blubs[j]] == 1)
				curState[k[d].blubs[j]] = 0;
			else
				curState[k[d].blubs[j]] = 1;
		}		
	}
}

int main()
{
	scanf("%d%d", &n, &m);
	
	int kk;
	for (int i = 1 ; i <= m ; i++)
	{
		scanf("%d", &kk);
		for (int j = 0 ; j < kk ; j++)
		{
			int pk;
			scanf("%d", &pk);
			int pp = k[pk].szBlub;
			k[pk].blubs[pp] = i;
			k[pk].szBlub++;
		}
	}
	
	for (int i = 1 ; i <= m ; i++)
		scanf("%d", &(p[i]));
	
	memset(curState, 0, sizeof(curState));
	
	numCount = 0;
	doSearch(1);
	
	printf("%d\n", numCount);
	
	return 0;
}


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

using namespace std;

const int maxn = 1e5+10;
const int inf = 2e9+10;

int num[maxn], dp[maxn];

int main(void)
{
	int n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++)
		cin >> num[i];

	for (int i = 2; i <= n; i++)
		dp[i] = inf;

	for (int i = 2; i <= n; i++)
		for (int j = i-1; j >= max(1, i-k); j--)
			dp[i] = min(dp[i], dp[j]+abs(num[i]-num[j]));

	cout << dp[n] << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;

template<int MOD> struct Fp {
    ll val;
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


//const int MOD = 998244353;
const int MOD = 1e9 + 7;
const int N_MAX = 2e5+5;
using mint = Fp<MOD>;
//mint:型

mint fact[N_MAX];
void init(){
  fact[0] = 1,fact[1] = 1;
  for(int i = 2; i < N_MAX; i++){
    fact[i] = fact[i-1] * i;
  }
}

mint inv(mint n){
  return (mint)1/n;
}

//二項係数の計算(mod)
mint COM(int n, int k){
  if(n<k) return 0;
  return fact[n]/(fact[k]*fact[n-k]);
}

int main(void){
  int N;cin >> N;
  mint A,B,C; cin >> A >> B >> C;
  mint A_exp[N+1],B_exp[N+1];
  A/=((mint)100-C);
  B/=((mint)100-C);
  C/=(mint)100;
  A_exp[0] = 1;
  B_exp[0] = 1;
  init();
  int i;REP(i,N){
      A_exp[i+1] = A * A_exp[i];
      B_exp[i+1] = B * B_exp[i];
  }

  mint ans = 0;
  for(int M = N; M < 2*N; M++){
    ans += COM(M-1,N-1) * M * (A_exp[N]*B_exp[M-N] + A_exp[M-N]* B_exp[N] )/((mint)1-C);
  }
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string s1, s2;
  cin >> s1 >> s2;
  ll ans = 0;
  int index = 0;
  bool vertical;
  if(s1[0] != s2[0]) ans = 6, index = 2, vertical = false;
  else ans = 3, index = 1, vertical = true;

  for(;index < N;){
    if(index == N-1 || s1[index] == s2[index]){
      if(vertical) ans *= 2;
      ans %= MOD;
      index++;
      vertical = true;
    }else{
      if(vertical) ans *= 2;
      else ans *= 3;
      ans %= MOD;
      index+=2;
      vertical = false;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}

main(){
    int a,b;
    cin>>a>>b;
    cout<<6-a-b<<endl;
}

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

int main()
{
    int n, x = 0;
    scanf("%d", &n);
    //printf("%d",n);
    char s[n];
    scanf("%s",s);

    int k, j = 0;

    for(k = 0; k <n+1 ; k++ )
    {
        if( s[k] == 'I')
        {
            x++;
        }
        else if( s[k] == 'D')
        {
            x--;
        }
        if( x > j)
            j = x;
    }
    printf("%d", j);

    return 0;
}


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

using namespace std;

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

#define mm 100005
#define nn 1005
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define cases int t;  cin>>t;   while(t--)
#define check(a,n) forn(iiii,int(n)) cout<<ll(a[iiii])<<" "; cout<<endl
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    fast_io;
    ll k;
    cin>>k;
    cout<<50<<endl;
    ll a[50];
    forn(i,50)
        a[i]=k/50+49;
    forn(i,k%50)
    {
        a[i]+=50-k%50+1;
    }
    reverse(a,a+50);
    forn(i,50-k%50)
        a[i]-=k%50;
    check(a,50);
    return 0;
}


Measured memory_bytes: 256
N, M, C=map(int, input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for _ in range(N)]
ans=0
for i in range(N):
	tmp=0
	for j in range(M):
		tmp+=A[i][j]*B[j]
	tmp+=C
	if tmp>0:
		ans+=1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rg register
#define int ll
char s[10000];
ll k;
char c[300];
int cnt;
signed main()
{
	cin>>s;
	cin>>k;
	int len=strlen(s);
	if(len==1)
	{
		if(k%2==0)
		{
			cout<<(k)/2;
		}
		else
		{
			cout<<(k-1)/2;
		}
		return 0;
	}
	if(s[0]!=s[len-1])//首尾不等 
	{
		ll ans=0;
		ll tot=0;
		for(rg int i=0;i<len;++i)
		{
			if(s[i]==s[i+1]) 
			{
				++tot;
			}
			else
			{
				++tot;
				if(tot%2==0)
				{
					ans+=tot/2;
				}
				else
				{
					ans+=(tot-1)/2; 
				}
				tot=0;
			}
		}
		cout<<ans*k;
	}
	else
	{
		int tp=1;
		for(rg int i=0;i<len-1;++i)
		{
			if(s[i]!=s[i+1]) tp=2;
		}
		if(tp==1)
		{
			ll sc=len*k;
			if(sc%2==0)
			{
				cout<<sc/2;
			}
			else
			{
				cout<<(sc-1)/2;
			}
			return 0;
		}
		int tag1=0;
		int tag2=len-1;
		char st=s[0];
		for(rg int i=0;i<len;++i)
		{
			if(s[i]==st) tag1=i;
			else break;
		}
		for(rg int i=len-1;i>=0;--i)
		{
			if(s[i]==st) tag2=i;
			else break;
		}
		ll tot1=0;
		ll tot=0;
		for(rg int i=0;i<len;++i)
		{
			if(s[i]==s[i+1]) ++tot;
			else
			{
				++tot;
				if(tot%2==0)
				{
					tot1+=tot/2;
				}
				else
				{
					tot1+=(tot-1)/2; 
				}
				tot=0;
			}
		}
//		cout<<"ss"<<endl;
//		system("pause");

		ll ans=0;
		for(rg int i=0;i<=len-1;++i) s[i+len]=s[i];
		for(rg int i=tag2;i<=2*(len-1)+1;++i)
		{
			if(i>tag2+len-1) break;
			c[++cnt]=s[i];
		}
		tot=0;
	//	puts("xzyakioi");
	//	cout<<"cnt="<<cnt<<endl;
		for(rg int i=1;i<=cnt;++i)
		{
			if(c[i]==c[i+1]) ++tot;
			else
			{
				++tot;
				if(tot%2==0) ans+=tot/2;
				else ans+=(tot-1)/2; 
				tot=0;
			}
		}
		cout<<ans*(k-1)+tot1;
	//	cout<<"asdasd"<<endl;
	}
//	cout<<"wry"<<endl;
//	int nm=0;
//	for(rg int i=1;i<=10;++i) ++nm;
//	cout<<"nm="<<nm<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		if (a + b >= 10) {
			System.out.println("error");
		} else {
			System.out.println(a + b);
		}

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    
    rep(i, n - 2) {
        if (a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2]) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()
	n := readInt()
	T := readInt()

	t := make([]int, n)
	for i := range t {
		t[i] = readInt()
	}

	ans := T
	for i := 0; i < n-1; i++ {
		ans += minInt(T, t[i+1]-t[i])
	}

	println(ans)
}

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

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 5120