akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	cin >> n;
	Vi b(n);
	rep(i, n) { cin >> b[i]; }
	Vi ans;
	bool can = true;
	while (!b.empty() and can == true) {
		can = false;
		for (int i = b.size() - 1; i >= 0 and can == false; i--) {
			if (b[i] == i + 1) {
				ans.push_back(b[i]);
				b.erase(b.begin() + i);
				can = true;
			}
		}
	}
	if (can == false) {
		cout << -1 << endl;

		return 0;
	}
	reverse(all(ans));
	repi(itr, ans) { cout << (*itr) << endl; }
}
/*
1 2 1
0 0 2
[1] [1 2]

2 2
- 0 -> -1

1 1 2
0 1 1
[1 2] [1]

1 2 3
0 0 0
[1 2 3]


1 1 1 2 2 1 2 3 2
0 1 2 2 3 5 5 5 7

[2][1 2 3] [2][1 2][1]

[1 1] 1 2 2 1 2 3 2
1 [2] 2 1 2 3 2		: 1 1
[1 2] 1 2 3 2		: 1 1 2
1 2 [3] 2		: 1 1 2 2 1
1 [2] 2: 1 1 2 2 1 3
1 1 2 2 1 3 2 2 1
*/

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long int func(ll a){
  if(a % 4 == 3)return 0;
  else if(a % 4 == 0) return a;
  else if(a % 4 == 1) return 1;
  else if(a % 4 == 2) return a^1;
}
ll max(ll a,ll b){
  if(a > b) return a;
  else return b;
}

int main(){
  ll A,B;
  cin >> A >> B;
  ll zero = 0;
  A = max(zero,A-1);
  ll ans = func(A)^func(B);
  cout << ans << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int c = a + b;
  int d = a - b;
  int e = a * b;

  int ans;
  ans = max (c, d);
  ans = max (ans, e);
  
  cout << ans << endl;
}

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

long long res = 0;
long long prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
	int j = 1;
	while (j * (j + 1) / 2 <= ret[i])
	{
		j++;
	}
	res += j-1;

  }
  if(n != 1) res++;
  return res;
}


int main() {
	long long n; cin >> n;
	cout << prime_factor(n) << endl;
	return 0;
}


Measured memory_bytes: 66120
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	A
# CreatedDate:  2020-06-13 21:01:06 +0900
# LastModified: 2020-06-13 21:01:28 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd


def main():
    s = input()
    print(s[0:3])


if __name__ == "__main__":
    main()


Measured memory_bytes: 9024
#include<stdio.h>
int main(void)
{
	int c1,c5,c10,c50,c100,c500,x,y,z;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	c1=c1*1;
	c5=c5*5;
	c10=c10*10;
	c50=c50*50;
	c100=c100*100;
	c500=c500*500;
	x=c1+c5+c10+c50+c100+c500;
	if(x>=1000){
		printf("1\n");
	}
	else if(x<1000){
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 2604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, T;
  cin >> N >> T;
  int ans = 0;
  int pre_t = 0;
  cin >> pre_t;
  rep(i, N - 1)
  {
    int t;
    cin >> t;
    if (t - pre_t < T)
      ans += t - pre_t;
    else
      ans += T;
    pre_t = t;
  }
  ans += T;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a = int(input())
b = list(map(int,input().split()))
cnt = 0
is_even = True

while is_even:
    tmp = []
    for i in b[:a]:

        if i % 2:
            is_even=False
            break
        else:
            tmp.append(i//2)

    if is_even:
        cnt+=1
        b = tmp

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 100005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n;
LL E, T, p[MAXN], dp[MAXN];

void init() {
    read(n);
    read(E); read(T);
    for (int i = 1; i <= n; ++i) {
        read(p[i]);
    }
}

void solve() {
    LL mn = 1e18;
    for (int i = 1, j = 0; i <= n; ++i) {
        while (T <= (p[i] - p[j + 1]) * 2) {
            mn = min(mn, dp[j] - p[j + 1] * 2);
            ++j;
        }
        if (j < i) {
            dp[i] = min(mn + p[i] * 2, dp[j] + T);
        } else {
            dp[i] = mn + p[i] * 2;
        }
    }
    printf("%lld\n", dp[n] + E);
}

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


Measured memory_bytes: 5272
#include <stdio.h>

int main(void)
{
  long long int x[6];
  scanf("%lld %lld %lld %lld %lld", &x[1], &x[2], &x[3], &x[4], &x[5]);
  for(long long int i=1;i<=5;i++){
    if(x[i]==0){
      printf("%lld\n", i);
    }
  }
  return 0;
}


Measured memory_bytes: 1708
#include<stdio.h>
typedef long long int ll;
int main()
{
    ll a,b,c,d,e,f,g,h,s;
    while(~scanf("%lld%lld%lld",&a,&b,&c))
    {
        e=a<b?a:b;
    f=e<c?e:c;
    e=a>b?a:b;
    g=e>c?e:c;
    h=a+b+c-f-g;
    s=h*f/2;
    printf("%lld\n",s);
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
ll mod=1000000007;
typedef pair<int, int> P;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c-(a-b), 0) << endl;


    return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  int h[110000];
  rep(i,n)
  cin >> h[i];
  int dp[n];
  rep(i,n)
  dp[i]=1e9;
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++)
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    string s,t;
    cin>>s>>t;
    for(char&i:s)i-='a'-1;
    for(char&i:t)i-='a'-1;
    vector<char>change(27);
    for(ll i=0;i<s.size();i++)change[s[i]]=t[i];
    for(ll i=0;i<s.size();i++)if(t[i]!=change[s[i]])return puts("No")&0;
    sort(change.begin(),change.end());
    for(ll i=0;i<26;i++)if(change[i]&&change[i]==change[i+1])return puts("No")&0;
    puts("Yes");
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,f,i,j,k,l,s;
    cin>>a>>b>>c;
    s=0;
    if(a==b&&b==c)
    {
        cout<<s<<endl;
    }
    else
    {

        if(a<=b&&b<=c)
        {
            i=a;
            j=b;
            k=c;
        }
        else if(a<=c&&c<=b)
        {
            i=a;
            j=c;
            k=b;
        }
        else if(b<=a&&a<=c)
        {
            i=b;
            j=a;
            k=c;
        }
        else if(c<=a&&a<=b)
        {
            i=c;
            j=a;
            k=b;
        }
        else if(b<=c&&c<=a)
        {
            i=b;
            j=c;
            k=a;
        }
        else if(c<=b&&b<=a)
        {
            i=c;
            j=b;
            k=a;
        }
        while(1)
        {
            if(i==j&&j==k)
            {
                break;
            }
            if(i<j&&j<k)
            {
                i++;
                j++;
                s++;
            }
            else if(i==j&&j<k)
            {
                i++;
                j++;
                s++;
            }
            else if(j==k&&i<j)
            {
                i+=2;
                s++;
            }
            else if(j==k&&i>j)
            {
                j++;
                k++;
                s++;
            }
        }
        cout<<s<<endl;
    }
return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


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

    ll cnt = 0;
    rep(i, n){
        set<char> st;
        rep(j, 3) st.insert(s[j][i]);
        if(st.size() == 1) continue;
        if(st.size() == 2) cnt++;
        if(st.size() == 3) cnt += 2;
    }

    cout << cnt << endl;

    return 0;
}



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

int main() {
	string s;
	long long k;
	cin >> s >> k;
	for (int i = 0; i < s.size(); i++) {
		int tg = ('z' + 1) - s[i];
		if (s[i] == 'a')
			continue;
		if (tg <= k)
			k -= tg, s[i] = 'a';
	}
	if (k > 0) {
		long long tmp = k + (s[s.size() - 1] - 'a');
		tmp %= 26;
		s[s.size() - 1] = 'a' + tmp;
		}
	cout << s << endl;
	return 0;
}




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

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] numArr = new int[N];

		for (int i = 0; i < N; i++) {
			numArr[i] = s.nextInt();
		}
		Arrays.sort(numArr);

		int idx = 0;
		int count = 0;
		while (idx < N-1) {
			if (numArr[idx] < numArr[idx + 1]) {
				count++;
			}
			idx++;
		}
		System.out.println(count+1);
	}
}


Measured memory_bytes: 23636
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var k = cin.nextInt();
            Console.WriteLine(n%k==0? 0:1);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main(void) {
	int n, m;
	int i, j;
	int ans = 0;

	int h[10000];

	char s;
	char str[1000];

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

	int hako[6];

	hako[0] = n + m;
	hako[1] = n + l;
	hako[2] = m + l;
	
	ans = hako[0];
	for (i = 1; i < 3; i++) {
		if (ans > hako[i]) {
			ans = hako[i];
		}
	}



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

Measured memory_bytes: 128
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		try (Scanner sc = new Scanner(System.in);) {
			String a = sc.next();
			String[] b = a.split("");

			String c = a.toUpperCase();
			String[] d = c.split("");

			String flag = "WA";

			int countC = 0;
			for (String st : b) {
				if (st.equals("C")) {
					countC++;
				}
			}

			int countLower = 0;
			for (int i = 0; i < d.length; i++) {
				if (b[i].equals(d[i])) {
					countLower++;
				}
			}

			boolean cc = false;
			for (int i = 2; i < d.length-1; i++) {
				if (b[i].equals("C")) {
					cc = true;
				}
			}
			
			
			if (b[0].equals("A")) {
				if (cc) {
					if (countC == 1) {
						if (countLower == 2) {
							flag = "AC";
						}
					}
				}
			}
			System.out.println(flag);
		}

	}

}


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

using namespace std;

#define endl '\n'

int main()
{
#ifdef jcg
	assert(freopen("input.in", "r", stdin));
	// assert(freopen("output.out", "w", stdout));
#else
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	using BitSet = bitset<2000*2000>;
	BitSet dp;
	dp.set(0);

	int N;
	cin >> N;

	int sum = 0;
	for (int i = 0; i < N; ++i)
	{
		int X;
		cin >> X;
		dp |= (dp << X);
		sum += X;
	}

	sum = (sum + 1) / 2;
	while (!dp.test(sum)) ++sum;

	cout << sum << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;

ll MOD = 1e9+7;
ll N;
ll m[30][30];
ll check;
ll dp[21][1<<21];

ll dfs(ll d){
    ll ans = 0;
    if(dp[d][check] != -1) return dp[d][check];
    if(d == N-1){
        for(int i=0;i<N;i++){
            if(m[N-1][i] == 1 && ((check>>i)&1) == 0) ans++;
        }
        ans %= MOD;
        return dp[d][check] = ans;
    }
    for(int i=0;i<N;i++){
        if(m[d][i] == 1 && ((check>>i)&1) == 0){
            check += (1<<i);
            ans += dfs(d+1);
            check -= (1<<i);
        }
    }
    ans %= MOD;
    return dp[d][check] = ans;
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> m[i][j];
        }
    }
    check = 0;
    for(int i=0;i<21;i++){
        for(int j=0;j<1<<21;j++){
            dp[i][j] = -1;
        }
    }
    cout << dfs(0) << endl;
    return 0;
}

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

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int pow(int a, int b) {
	int ans=1;
	rep(i,b) ans*=a;
	return ans;
}

int main() {
	int n,m;cin>>n>>m;
	int ans=pow(2,m)*((n-m)*100+m*1900);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
def gcd(a,b):
    a=abs(a)
    b=abs(b)
    if a<b:
        c=a
        a=b
        b=c
    if a%b==0:
        return b
    else:
        return gcd(b,a%b)
n,x = map(int,input().split())
xlist= list(map(int,input().split()))
ans=x-xlist[0]
for i in xlist:
    ans=gcd(ans,x-i)
print(ans)

Measured memory_bytes: 14224
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions

k = int(stdin.readline().rstrip())
t = stdin.readline().rstrip().split()
a = int(t[0])
b = int(t[1])
tes = False

for el in range(a, b+1):
    if el % k == 0:
        tes = True
        print('OK')
        break
if not tes:
    print('NG')


Measured memory_bytes: 72700
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    x, t = i_map()

    print(x - t if x - t >= 0 else 0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 76604
#include <stdio.h>

long long n, m;

int main() {
	scanf("%lld%lld", &n, &m);
	if(n > m) {
		int h = m;
		m = n;
		n = h;
	}
	if(n == 1) {
		if(m == 1) {
			printf("1\n"); return 0;
		} else {
			printf("%lld\n", m - 2); return 0;
		}
	} else {
		long long response = (n - 2) * (m - 2); 
		printf("%lld\n", response); return 0;
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fill(arr,c) memset(arr,c,sizeof(arr))
#define perm(r) next_permutation(all(r))
//it gives bool value ans permute the string lexoggraphically
#define sortdesc greater<int>()
#define ll long long int 
#define f(i,a) for(int i=0;i<a;i++)
#define fo(i,a) for(int i=1;i<=a;i++)
#define foo(i,x,n,c) for(ll i=x;i<n;i+=c)
#define foi(i,x,n,c) for(ll i=x;i>=n;i+=c)
#define fauto(i,m) for(auto i:m)
#define forall(a) for( auto itr=a.begin();itr!=a.end();itr++)
#define ld long double
#define in push_back
#define mll map<ll,ll>
#define mcl map<char,ll>
#define msl map<string,ll>
#define vi vector<int >
#define vl vector<ll >
#define vp vector< pair<int,int> >
#define vs vector <string> 
#define vc vector <char> 
#define o(a) cout<<a
#define os(a) cout<<a<<" "
#define en cout<<"\n";
#define testcase ll t ;cin>>t; while(t--)
#define ff first
#define ss second
#define pl pair<ll,ll>
#define pi pair<int,int>
#define all(a) (a).begin(), (a).end()

#define sz(a)  (a).size()
#define prec(n) fixed<<setprecision(n)
#define mp make_pair
#define bitcount  __builtin_popcountll
#define imin o("imin");en;
using namespace std;
bool comp(const pair<int,int> &a , const pair<int,int> &b){
    if(a.first == b.first)  return a.second < b.second;
     return a.first < b.first;
}
bool comps(const pair<int,int> &a , const pair<int,int> &b){
    if(a.second == b.second)  return a.first< b.first;
     return a.second < b.second;
}
//ll pi=acos(0.0)*2;
void fastio()
{
    	ios::sync_with_stdio(0);
cin.tie(0);

}
void inout()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

     freopen("output.txt", "w", stdout);
     #endif
}
	
ll lcm(ll a,ll b)
{
	return (a*b)/__gcd(a,b);
}
int main()
{
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll x=max(a*c,max(b*d,max(b*c,a*d)));
o(x);

return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  int m, d;
  cin >> m >> d;

  int ans = 0;
  rep(i, 1, m+1) rep(j, 1, d+1){
    if(j >= 10 and j%10 >= 2 and j/10 >= 2 and (j%10) * (j/10) == i){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int i,j;
bool yj=false;
int absmin=1e9,mini;
int n,X;
cin>>n>>X;
vector<int>x(n);
for(i=0;i<n;i++){
cin>>x[i];
x[i]-=X;
if(abs(x[i])<absmin){
absmin=abs(x[i]);
mini=i;
}
}
for(i=absmin;i>0;i--){
for(j=0;j<n;j++){
if(x[j]%i!=0){
yj=true;
break;
}
}
if(yj==true)yj=false;
else{
cout<<i<<endl;
return 0;
}
}
return 0;


}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    string s;
    cin >> s;

    if (s.size() == 3) {
        reverse(ALL(s));
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, m, choice[101000][51];
ll MOD = 1e9+7;

ll choiceINIT(ll n_choice){
	for(ll i = 0; i <= n_choice; i++){for(ll j = 0; j <= 50; j++){choice[i][j] = 0;}}
	choice[0][0] = 1;
	for(ll i = 1; i <= n_choice; i++){
		choice[i][0] = 1;
		for(ll j = 1; j <= 50; j++){
			choice[i][j] = (choice[i-1][j-1]+choice[i-1][j])%MOD;
		}
	}
	return 0;
}

int main(){
	cin >> n >> m;
	choiceINIT(n+50);
	
	ll ans = 1;
	for(ll i = 2; i*i <= m; i++){
		ll cnt = 0;
		while(m%i == 0){
			m /= i;
			cnt++;
		}
		if(cnt){
			ans *= choice[n-1+cnt][cnt];
			ans %= MOD;
		}
	}
	if(m > 1){
		ans *= n;
		ans %= MOD;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 40192
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int h, w, K;
string s[10];

signed main() {
	int i, j;
	
	cin >> h >> w >> K;
	rep(i, h) cin >> s[i];
	
	int ans = 114514;
	rep(i, 1 << (h - 1)) {
		vector<int> ys;
		ys.push_back(0);
		rep(j, h - 1) {
			if ((i >> j) % 2) {
				ys.push_back(j + 1);
			}
		}
		ys.push_back(h);
		
		int cnt[12] = {0};
		int prev = 0;
		int cut = 0;
		rep(j, w) {
			int k, y;
			rep(k, (int)ys.size() - 1) {
				for (y = ys[k]; y < ys[k + 1]; y++) {
					cnt[k] += s[y][j] - '0';
				}
				if (cnt[k] > K) break;
			}
			
			if (k < (int)ys.size() - 1) {
				//cout << "cut_j = " << j << endl;
				if (prev == j) break;
				prev = j;
				cut++;
				
				rep(k, (int)ys.size()) cnt[k] = 0;
				rep(k, (int)ys.size() - 1) {
					for (y = ys[k]; y < ys[k + 1]; y++) {
						cnt[k] += s[y][j] - '0';
					}
				}
			}
		}
		if (j == w) {
			int res = ys.size() - 2 + cut;
			ans = min(ans, res);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

vector<int> hamming;
set<int> used;
void add_hamming(int n)
{
	if (n > 1000000 || used.count(n))
		return;
	used.insert(n);
	hamming.push_back(n);
	add_hamming(2*n);
	add_hamming(3*n);
	add_hamming(5*n);
}
int main()
{
	add_hamming(1);
	sort(hamming.begin(), hamming.end());

	int n, m;
	while (scanf("%d %d", &n, &m), n)
		printf("%d\n", upper_bound(hamming.begin(), hamming.end(), m)
		- lower_bound(hamming.begin(), hamming.end(), n));

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 212345;
const ll mod = 1000000007;
const int off = 2500;
int v[55], n, m;
ll dp[5555];
/*
ll sol (int i, int sum) {
    if (i == n) {
        return sum == off;
    }
    bool &is = seen[i][sum];
    ll &ans = dp[i][sum];
    if (is) return ans;
    is = 1;
    return ans = sol(i+1, sum) + sol(i+1, v[i]+sum);
    
}
*/
int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i<=n; ++i) {
        scanf("%d", v+i);
        v[i]-=m;
    }
    dp[off] = 1;
    for (int i = 1; i<=n; ++i) {
        if (v[i] < 0) {
            for (int j = 2*off; j+v[i]>=0; --j) {
                dp[j] += dp[j+v[i]];
            }
        } else {
            for (int j = 0; j+v[i]<=2*off; ++j) {
                dp[j] += dp[j+v[i]];
            }
        }
    }
    printf("%lld\n", dp[off]-1LL);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
int fun(string s)
{
    int n=s.size(),i,j;
    for(i=0,j=n-1;i<j;i++,j--)
    {
        if(s[i]!=s[j])
           return 0;
    }
    return 1;
}
signed main()
{
   string s;
   cin>>s;
   int n=s.size();
   string p=s.substr(0,(n-1)/2);
   string q=s.substr((n+3)/2-1,s.size());
  
   if(fun(s)&&fun(p)&&fun(q))
   cout<<"Yes"<<endl;
   else
   cout<<"No"<<endl;
   
}

Measured memory_bytes: 256
Q = int(input())
lr_list = [[int(i) for i in input().split()] for i in range(Q)]

is_prime = [1 for i in range(10**5+1)]
is_prime[0] = is_prime[1] = 0
for i in range(10**5+1):
    if not is_prime[i]:
        continue
    for j in range(i*2, 10**5+1, i):
        is_prime[j] = 0
        
a = [0 for i in range(10**5+1)]
for i in range(10**5+1):
    if i % 2 == 0:
        continue
    if is_prime[i] and is_prime[(i+1)//2]:
        a[i] = 1
        
s = [0 for i in range(10**5+2)]
for i in range(10**5+1):
    s[i+1] = s[i] + a[i]
    
for i in range(Q):
    lr = lr_list[i]
    print(s[lr[1]+1] - s[lr[0]])

Measured memory_bytes: 26560
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x);
#define bb(x)      cerr<< x <<endl;
#define ii         pair<int,int>
#define vi         vector<int>
#define fr         first
#define se         second
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M   = 1e7+9 ;
const ll inf = 1e19  ;
const int si = 1e5+9 ;
//////////////////////    Hi    ^_^  hack me if you can :P
int n;
ll h,w,a,b;
vector<pair<ll,ll>>v;
int main()
{
    cin>>h>>w>>n;
    lop(i,n)
    {
        cin>>a>>b;
        a--,b--;
        for (ll j=a-1; j<=a+1; j++)
        {
            for(ll k=b-1; k<=b+1; k++)
            {
                if(1<=j&&j<h-1&&1<=k&&k<w-1)
                {
                    v.pb({j,k});
                }
            }
        }
    }
    sort(all(v));
    int c=0;
    ll ans[10]= {(h-2)*(w-2)};
    for (int i=0; i<sz(v); i++)
    {
        if(i!=0&&v[i].first!=v[i-1].first||v[i].second!=v[i-1].second)
        {
            c=0;
        }
        ans[c]--;
        ans[++c]++;
    }
    lop(i,10)
    {
        cout<<ans[i]<<endl;
    }
    r0;
}


/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,1,1,-1,-1,-1};
int my[]= {1,-1,0,1,-1,0,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}
*/


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

#define ll long long
int main()
{
	ll n, k;
	cin >> k >> n;
	ll arr[n];
	for(auto &x: arr) cin >> x;
	sort(arr, arr+n);

	ll store=arr[n-1];
	ll a[n];
	a[0]=arr[0];
	for(int i=1;i<n;++i){
		a[i]=arr[i]-arr[i-1];
	}
	
	a[0]=(k-store)+arr[0];
	ll sum=accumulate(a, a+n, 0);
	ll MIN=1e18+7;
	
	for(int i=0;i<n;++i){
		MIN=min(MIN, sum-a[i]);
	}

	cout << MIN << '\n';
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
struct Bit {
  vector<int> bit;
  Bit(int N) : bit(N+1) {};
  void add(int a, int w) {
    while(a < bit.size()) {
      bit[a] += w;
      a += a & -a;
    }
  }
  int sum(int a) {
    int s = 0;
    while(a > 0) {
      s += bit[a];
      a -= a & -a;
    }
    return s;
  }
};
struct Query {
  int l, r, idx;
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, Q;
  cin >> N >> Q;
  vector<int> c(N);
  REP(i, N) cin >> c[i];
  REP(i, N) c[i]--;
  vector<Query> que(Q);
  REP(i, Q) {
    cin >> que[i].l >> que[i].r;
    que[i].l--; que[i].r--;
    que[i].idx = i;
  }
  sort(ALL(que), [](auto const &a, auto const &b) { return a.r < b.r; });
  vector<int> last(N);
  vector<int> ans(Q);
  int ridx = -1;
  Bit bit(N);
  REP(i, Q) {
    while(ridx < que[i].r) {
      ridx++;
      if(last[c[ridx]] != 0) bit.add(last[c[ridx]], -1);
      bit.add(ridx+1, 1);
      last[c[ridx]] = ridx+1;
    }
    ans[que[i].idx] = bit.sum(que[i].r+1) - (que[i].l > 0 ? bit.sum(que[i].l) : 0);
  }
  REP(i, Q) cout << ans[i] << "\n";
}

Measured memory_bytes: 17400
freq = Hash.new(0)
longest_size = -1
longest_word = ""

words = gets.chomp.split(" ")
words.each{|word|
    freq[word] += 1
    if word.size > longest_size
        longest_word = word
        longest_size= word.size
    end
}

most_freq = freq.to_a.sort_by{|item| -item[1]}.first[0]
puts "#{most_freq} #{longest_word}"

Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>
 
using namespace std;
 
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n = 5;
	int s = 0;
	while (n--) {
		int x;
		cin >> x;
		s += x;
	}
	cout << 1 + 2 + 3 + 4 + 5 - s << endl;
}

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

int main() {
	long long n;
	cin >> n;
	long long ans = 0;
	rep2(x, 1, n) {
		long long y = n / x;
		long long g = x * (1 + y) * y / 2;
		ans += g;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <algorithm>
#define i64 long long
#define pii pair<i64, i64>
#define fi first
#define se second
using namespace std;

const int N = 2e5 + 10;
const i64 inf = 1e16;
int n, q, a, b, x[N];

struct node {
	i64 v, mn1, mn2, tag;
} tr[N * 4];

void build(int o, int l, int r) {
	tr[o] = (node) {inf, inf, inf, 0};
	if (l == r) return;
	int mid = l + r >> 1;
	build(o << 1, l, mid);
	build(o << 1 | 1, mid + 1, r);
}

void update(int x, i64 v) {
	tr[x].v += v, tr[x].tag += v;
	tr[x].mn1 += v, tr[x].mn2 += v;
}

void pushdown(int o) {
	if (!tr[o].tag) return;
	update(o << 1, tr[o].tag);
	update(o << 1 | 1, tr[o].tag);
	tr[o].tag = 0;
}

void modify(int o, int l, int r, int p, i64 v) {
	if (l == r) {
		tr[o].v = min(tr[o].v, v);
		tr[o].mn1 = tr[o].v - l;
		tr[o].mn2 = tr[o].v + l;
		return;
	}
	pushdown(o);
	int mid = l + r >> 1;
	if (p <= mid) modify(o << 1, l, mid, p, v);
	else modify(o << 1 | 1, mid + 1, r, p, v);
	tr[o].mn1 = min(tr[o << 1].mn1, tr[o << 1 | 1].mn1);
	tr[o].mn2 = min(tr[o << 1].mn2, tr[o << 1 | 1].mn2);
	tr[o].v = min(tr[o << 1].v, tr[o << 1 | 1].v);
}

pii query(int o, int l, int r, int x, int y) {
	if (x <= l && r <= y) return pii(tr[o].mn1, tr[o].mn2);
	pushdown(o);
	int mid = l + r >> 1;
	pii a(inf, inf), b(inf, inf);
	if (x <= mid) a = query(o << 1, l, mid, x, y);
	if (y > mid) b = query(o << 1 | 1, mid + 1, r, x, y);
	return pii(min(a.fi, b.fi), min(a.se, b.se));
}

int main() {
	scanf("%d %d %d %d", &n, &q, &a, &b);
	for (int i = 1; i <= q; ++ i) scanf("%d", &x[i]);
	x[0] = b;
	build(1, 1, n);
	modify(1, 1, n, a, 0);
	for (int i = 1; i <= q; ++ i) {
		pii t1 = query(1, 1, n, 1, x[i]);
		pii t2 = query(1, 1, n, x[i], n);
		int tp = abs(x[i] - x[i - 1]);
		tr[1].tag += tp, tr[1].v += tp;
		tr[1].mn1 += tp, tr[1].mn2 += tp;
		modify(1, 1, n, x[i - 1], t1.fi + x[i]);
		modify(1, 1, n, x[i - 1], t2.se - x[i]);
	}
	printf("%lld\n", tr[1].v);
	return 0;
}


Measured memory_bytes: 19328
using System;

namespace ABC171B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, k;
            var aa = Console.ReadLine().Split(" ");
            n = int.Parse(aa[0]);
            k = int.Parse(aa[1]);
            int x = 0;
            int[] a = new int[n ];
            var ac = Console.ReadLine().Split(" ");
            for (int i = 0; i < n; i++)
                a[i] = int.Parse(ac[i]);

            Array.Sort(a,(e,b) => e-b);

            for (int i = 0; i < k; i++)
            {
                //Console.WriteLine(a[i]);
                x += a[i];
            }
            Console.WriteLine(x);

        }
    }
}


Measured memory_bytes: 18580
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[100],d,f,g,h,j,i;
	scanf("%d",&a);
	for(i=0;i<a;i++) scanf("%d",&s[i]);
	for(i=a;i>0;i--){
		d=0;
		for(j=0;j<a;j++) if(s[j]>=i) d++;
		if(d>=i) break;
	}
	printf("%d\n",i);
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N,M;
  cin>>N>>M;
  vector<bool> isAC(N, false);
  vector<int> check(N,0);
  int wans=0, cans=0;
  int p;
  string s;
  for(int i=0; i<M; i++){
    cin>>p>>s;
    if(isAC.at(p-1)) continue;
    else{
      if(s=="AC"){
        isAC.at(p-1) = true;
        cans++;
        wans+=check.at(p-1);
      }
      else{
        check.at(p-1)++;
      }
    }
  }
  cout<<cans<<" "<<wans<<"\n";
}

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

const int INF = 1 << 29;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> costs(n, 0);
    vector<vector<int>> a(n, vector<int>(m, 0));

    rep(i, n)
    {
        cin >> costs[i];
        rep(j, m) cin >> a[i][j];
    }

    int min_cost = INF;
    rep(i, 1 << n)
    {
        int cost = 0;
        vector<int> status(m, 0);
        rep(j, n)
        {
            if (i >> j & 1)
            {
                cost += costs[j];
                rep(k, m) status[k] += a[j][k];
            }
        }
        bool flag = true;
        rep(j, m) flag &= (status[j] >= x);
        if (flag)
        {
            min_cost = min(min_cost, cost);
        }
    }
    cout << (min_cost != INF ? min_cost : -1) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
  int ans=0,temp=0;
  string s;
  cin>>s;
  for(auto c: s) {
    if(c=='A'||c=='T'||c=='G'||c=='C')ans=max(ans,++temp);  
    else temp=0;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main()
{
    long long N, K;
    cin >> N >> K;
    long long ans = 0;
    long long mod = 1000000007;
    for (long long i = K; i <= N + 1; i++)
    {
        long long min = (i - 1) * i / 2;
        long long max = (2 * N - i + 1) * i / 2;
        ans += max - (min - 1);
        ans %= mod;
    }
    cout << ans << '\n';
    return 0;
}

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

a = [0]*5
n = int(input())
a[0] = int(input())
a[1] = int(input())
a[2] = int(input())
a[3] = int(input())
a[4] = int(input())

bottle = min(a[0],a[1],a[2],a[3],a[4])

time = 0

if n % bottle == 0:
    time = int(n / bottle)
else:
    time = int(n // bottle) + 1

if bottle >= n:
    print(5)
else:
    print(time+4)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

int main(){
	ios
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		cout<<'x';
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
int val[100001][3];
int DP[100001][3];
signed main() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>val[i][0]>>val[i][1]>>val[i][2];
    DP[0][0]=0,DP[0][1]=0,DP[0][2]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            int j1 = (j+1)%3,j2 = (j+2)%3;
            DP[i+1][j] = max(DP[i][j1] + val[i][j1], DP[i][j2] + val[i][j2]);
        }
    }
    cout<<max(DP[n][0],max(DP[n][1],DP[n][2]));
    return 0;
}

Measured memory_bytes: 4992
import java.io.*;
import java.util.*;
class Graph2 {
	private int[] dist;
	private int[] visited;
	private int[] indgree;
	LinkedList<Integer> sorting = new LinkedList<Integer>();
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	/*public void addEdges(int i, int j) {
		adjList.get(i).add(j);
	}*/
	public Graph2() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		dist = new int[totalVertex];
		indgree = new int[totalVertex];
		/*for (int i = 0; i < dist.length; i++) {
			dist[i] = -1;
		}*/
		visited = new int[totalVertex];
		for (int j = 0; j < visited.length; j++) {
			visited[j] = 0;
		}
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			adjList.add(tmp);
		}
		int totalEdges = in.nextInt(); 
		for (int k = 0; k < totalEdges; k++) {
			int source = in.nextInt();
			int target = in.nextInt();
			adjList.get(source).add(target);
			indgree[target]++;
		}
		in.close();
	}
	public void DFS(int v) {
		for(int k : adjList.get(v)) {
			if (visited[k] == 0) {
				visited[k] = 1;
				DFS(k);
			}
		}
		sorting.addFirst(v);
	}
	public void ST() {
		for(int i = 0; i < totalVertex; i++) {
			if (indgree[i] == 0) {
				DFS(i);
			}	
		}
		while(!sorting.isEmpty()) {
			 System.out.println(sorting.remove());	
	}
	}
}
public class Main {
	public static void main(String argv[]) {
		Graph2 g = new Graph2();
		g.loadAdjList();
		g.ST();
	}
}


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

int main(void){
  int a,b,c,d;
  int turn = 1;
  cin >> a >> b >> c >> d;
  while(1){
    if (turn>0){c-=b;}
    else{a-=d;}
    turn = turn * -1;
    if (a<=0){cout <<"No\n"; break;}
    if (c<=0){cout << "Yes\n"; break;}
  }
  return 0;
}

Measured memory_bytes: 3636
eval'N,*A='+`dd`.split*?,
f=->a{l=[[0,i=-1]]
a.map{|x|l.pop while(t=l[-1])[0]>x
l<<[x,i+=1]
i-t[1]}}
r=0
A.zip(f[A],f[A.reverse].reverse){|a,b,c|r+=a*b*c}
p r

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

#define ll long long
#define ar array

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)

#define E_ACH2(x, a) for (auto& x: a)
#define E_ACH3(x, y, a) for (auto& [x, y]: a)
#define E_ACH4(x, y, z, a) for (auto& [x, y, z]: a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...) E_ACHC(__VA_ARGS__)(__VA_ARGS__)

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

	int n;
	cin >> n;
	cout << (1000-n%1000)%1000;
}

Measured memory_bytes: 3648
N = int(input())
mod = 10 ** 9 + 7
memo = [{} for i in range(N+1)]
#print (memo)


#4文字を与えて条件に合致するかを判断
def check(last4):
    for i in range(4):
        t = list(last4) #4文字をリストに格納
        if i >= 1: #最初の文字以外に着目する時
            t[i-1], t[i] = t[i], t[i-1] #i番目とi-1番目を交換
        if ''.join(t).count('AGC') >= 1: #AGCが含まれているかどうかの確認
            return False
    return True

def dfs(cur, last3): #深さ優先探索
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ATCG':
        if check(last3+c):
            ret = (ret+dfs(cur+1, last3[1:]+c))%mod
    memo[cur][last3] = ret
    return ret

print (dfs(0, 'TTT'))


#print (memo)

Measured memory_bytes: 3872
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final long MOD = 1000000007;
	public static final int TEN = 10;
	public static int[][] c = new int[TEN][TEN];
	public static int[] mana = new int[TEN];
	public static void main(String[] args) {
		int i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		int h = parseInt(sc.next());
		int w = parseInt(sc.next());
		for (i = 0; i < TEN; i++) {
			for (j = 0; j < TEN; j++) {
				c[i][j] = parseInt(sc.next());
			}
		}
		int[][] a = new int[h][w];
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				a[i][j] = parseInt(sc.next());
			}
		}
		sc.close();
		for (i = 0; i < TEN; i++) {
			if(i==1)continue;
			mana[i] = calcMana(i, 0);
		}
//		out.println(Arrays.toString(mana));
		int ans=0;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if(a[i][j]==-1)continue;
				ans+=mana[a[i][j]];
			}
		}
		out.println(ans);
	}
	public static int calcMana(int no, int num) {
		int mn;
//		out.printf("calcMana(%d)%n",no);
		if(mana[no]==0) {
			mn=c[no][1];
			for (int i = 0; i < TEN; i++) {
				if(i==no||i==1) continue;
				if(mn>c[no][i]+num) {
					int tmp=c[no][i]+calcMana(i, c[no][i]+num);
					if(mn>tmp) {
						mn = tmp;
					}
				}
			}
		} else {
			mn=mana[no];
		}
		return mn;
	}
}


Measured memory_bytes: 39020
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
typedef pair<int, int> ii;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
int n, m;
int l[M], r[M], d[M], mark[N];
long long sum[N];
vector<ii> adj[N];

void dfs(int u) {
	mark[u] = 1;
	for (ii v : adj[u]) {
		if (!mark[v.fi]) {
			sum[v.fi] = sum[u] + v.se;
			dfs(v.fi);
		}
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i ++) {
		scanf("%d%d%d", &l[i], &r[i], &d[i]);
		adj[l[i]].push_back(mp(r[i], d[i]));
		adj[r[i]].push_back(mp(l[i], -d[i]));
	}
	for (int u = 1; u <= n; u ++) {
		if (mark[u] == 0) {
			dfs(u);
		}
	}
	for (int i = 1; i <= m; i ++) {
		if (sum[r[i]] - sum[l[i]] != d[i]) {
			printf("No\n");
			exit(0);
		}
	}
	printf("Yes\n");
}

Measured memory_bytes: 14208
st = gets.chomp!.split(" ")
N = st[0].to_i

l = Array.new
st = gets.chomp!.split(" ")
for i in 0..N-1
    l[i] = st[i].to_i
end

l.sort!
x = l[l.size-1]
l.delete_at(l.size-1)

sum = 0
l.each do |i|
    sum += i
end

if x < sum
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }

            int sum = 0;
            ArrayList<Integer> s = new ArrayList<>();
            for (int i=0; i<n; ++i) {
                s.add(sc.nextInt());
                sum += s.get(i);
            }
            sum -= Collections.max(s);
            sum -= Collections.min(s);

            System.out.println((int)(sum / (n-2)));
        }
        sc.close();
    }
}



Measured memory_bytes: 29464
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main()
{
	int a,b,c;
	while(cin >> a >> b >> c)
	{
		int count=0;
		for(int i=1;i<=10;i++)
		{
			if(i==a||i==b||i==c)continue;
			if(a+b+i<=20)
			{
				count++;
			}
		}
		if(count>=4)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

const int maxn = 1e5 + 10;
int n, sum, a[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        sum += abs(a[i] - a[i - 1]);
    }
    a[n + 1] = 0;
    sum += abs(a[n + 1] - a[n]);
    for (int i = 1; i <= n; i++) {
        printf("%d\n", sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]));
    }
    return 0;
}

Measured memory_bytes: 1664