akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  vector<ll> p(n);
  rep(i,n){
    cin>>p[i];
  }

  sort(all(p));
  reverse(all(p));

  ll ans1=-1;
  ll ans2=-1;
  bool tobi=false;
  rep(i,n){
    if(tobi){
      tobi=false;
      continue;
    }
    if(ans1==-1 && i+1<n && p[i]==p[i+1]) {
      ans1=p[i];
      tobi=true;
      continue;
    }
    if(ans1!=-1 && i+1<n && p[i]==p[i+1]) {
      ans2=p[i];
      break;
    }
  }

  if(ans2==-1) cout << 0 << endl;
  else cout << ans1*ans2 << endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

int main(){
    int n = 0;
    std::cin >> n;
    std::vector<unsigned long long int> a(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> a[i];
        if (a[i] == 0)
        {
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    
    unsigned long long int prod = 1;
    for (int i = 0; i < n; i++)
    {
        if (a[i] <= 1000000000000000000LL / prod)
        {
            prod *= a[i];
        }
        else
        {
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    std::cout << prod << std::endl;

    return 0;
}

Measured memory_bytes: 3972
from collections import deque
n = int(input())
a = list(map(int,input().split()))
b_1 = deque()
b_2 = deque()
switch = 0
for i in a:
    if switch == 0:
        b_1.append(i)
        b_2.appendleft(i)
        switch = 1
    else:
        b_2.append(i)
        b_1.appendleft(i)
        switch = 0
b_1 = list(b_1)
b_2 = list(b_2)
if switch == 0:
    print(' '.join(list(map(str,b_1))))
else:
    print(' '.join(list(map(str,b_2))))


Measured memory_bytes: 38188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <map>
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define rep(i,l,r)  for(int i=l;i<=r;i++)
#define pre(i,r,l)  for(int i=r;i>=l;i--)
#define pii pair<int,int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const int maxn = 1000005;
inline int read(){
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}

int main() {
  ll n; cin >> n;
  string s;
  while(n > 0) {
    ll t = n%26;
    if(t == 0) s = 'z' + s;
    else s = char('a'+ t - 1) + s;
    n /= 26;
    if(t == 0) n--;
  }
  cout << s << endl;
}


Measured memory_bytes: 3596
using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);

			double k = (double)(a + b) / 2.0;
			if (k == (int)k)
			{
				Console.WriteLine(k);
			}
			else
			{
				Console.WriteLine("IMPOSSIBLE");
			}
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    if(n %2 == 0){
        for(int i = n-1; i>= 1; i-=2){
            cout << s[i] << " ";
        }
        for(int i= 0; i<= n-2; i+=2){
            cout << s[i] << " ";
        }
        cout << endl;
        return 0;
    }

    if(n %2 == 1){
        for(int i= n-1; i>= 0; i-=2){
            cout << s[i] << " ";
        }
        for(int i= 1; i<= n-2; i+=2){
            cout << s[i] << " ";
        }
        cout << endl;
        return 0;
    }

}
    

Measured memory_bytes: 3840
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    int h,w;
    cin >> h >> w;

    vector<string> str(h);

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

    vector<int> count(26,0);

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            count[str[i][j]-'a']++;
        }
    }

    priority_queue<int> pq;

    for(int i = 0; i < 26; i++){
        pq.push(count[i]);
    }

    int four = (h/2)*(w/2);
    int two = (h&1 ? w/2 : 0) + (w&1 ? h/2 : 0);
    int center = ((h&w)&1 ? 1 : 0);

    while(four > 0){
        if(pq.top() >= 4){
            int tmp = pq.top() - 4;
            pq.pop();
            pq.push(tmp);
            four--;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    while(two > 0){
        if(pq.top() >= 2){
            int tmp = pq.top() - 2;
            pq.pop();
            pq.push(tmp);
            two--;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=500010;
int a[N];
bool w[N];
long long s[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,q,D,x=0;
    cin>>n>>D;
    for(int i=1;i<=n;i++) a[i]=gi();
    for(int i=n;i;i--) {
	s[i]=s[i+1];
	if(s[i]>=a[i]/2) s[i]+=a[i];
    }
    cin>>q;
    for(int i=1;i<=n;i++) {
	int d=abs(D-x);
	w[i]=(s[i+1]<d);
	if(d+d>a[i]) x=(x<D?x+a[i]:x-a[i]);
    }
    while(q--) puts(w[gi()]?"YES":"NO");
    return 0;
}

Measured memory_bytes: 8320
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 3000;

int N;

ll A[MAX_N + 1], dp[MAX_N + 2][MAX_N + 2];

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

    cin >> N;

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

    for (int i = N; i >= 1; i--) {
        for (int j = i; j <= N; j++) {
            if (i < j) {
                if ((N + i - j - 1) & 1) {
                    dp[i][j] = min(dp[i + 1][j], dp[i][j - 1]);
                } else {
                    dp[i][j] = max(dp[i + 1][j] + A[i], dp[i][j - 1] + A[j]);
                }
            } else if (!((N + i - j - 1) & 1)) {
                dp[i][j] = A[i];
            }
        }
    }

    cout << 2 * dp[1][N] - sum << "\n";

    return 0;
}

Measured memory_bytes: 49788
#include<iostream>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	string p = "";
	for (int w = 1; w <= 5; w++) {
		p += "hi";
		if (p == s) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
		return 0; 
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
h    = gets.split.map(&:to_i)

dp = [10**18] * (10**5+10)
dp[0] = 0

(n-1).times do |i|
  k = n-i-1 if k > n-i-1
  k.times do |j|
    dp[i+j+1] = dp[i] + (h[i+j+1] - h[i]).abs  if dp[i+j+1] > dp[i] + (h[i+j+1] - h[i]).abs 
  end
end
 
 
p dp[n-1]

Measured memory_bytes: 10764
S = input()
ans1 = 0
ans2 = 0

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == '0':
            ans1 += 1
        else:
            ans2 += 1
    else:
        if S[i] == '0':
            ans2 += 1
        else:
            ans1 += 1
print(min(ans1, ans2))


Measured memory_bytes: 3188
#include <functional>  
#include <algorithm>  
#include <iostream>  
#include <fstream>  
#include <sstream>  
#include <iomanip>  
#include <numeric>  
#include <cstring>  
#include <cassert>  
#include <cstdio>  
#include <string>  
#include <vector>  
#include <bitset>  
#include <queue>  
#include <stack>  
#include <cmath>  
#include <ctime>  
#include <list>  
#include <set>  
#include <map> 
#include <bits/stdc++.h>

using namespace std;

#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  

#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 1000000007  
#define INF 0x3f3f3f3f  
#define EXP 1e-8  
#define lowbit(x) (x&-x)  
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int nobind = []() {std::ios::sync_with_stdio(false);cin.tie(NULL);return 0;}();

/*************************************** 
prime table 
O(n) 
***************************************/  
const int PRIMERANGE = 1000000;  
int prime[PRIMERANGE + 1];  
int getPrime() {  
    memset (prime, 0, sizeof (int) * (PRIMERANGE + 1));  
    for (int i = 2; i <= PRIMERANGE; i++) {  
        if (!prime[i]) prime[++prime[0]] = i;  
        for (int j = 1; j <= prime[0] && prime[j] <= PRIMERANGE / i; j++) {  
            prime[prime[j]*i] = 1;  
            if (i % prime[j] == 0) break;  
        }  
    }  
    return prime[0];  
}  
/*************************************** 
get factor of n 
O(sqrt(n)) 
factor[][0] is prime factor 
factor[][1] is factor generated by this prime 
factor[][2] is factor counter 

need: Prime Table 
***************************************/  
///you should init the prime table before  
long long factor[100][3], facCnt;  
long long getFactors(long long x) {  
    facCnt = 0;  
    long long tmp = x;  
    for(long long i = 1; prime[i] <= tmp / prime[i]; i++) {  
        factor[facCnt][1] = 1, factor[facCnt][2] = 0;  
        if(tmp % prime[i] == 0)  
            factor[facCnt][0] = prime[i];  
        while(tmp % prime[i] == 0)  
            factor[facCnt][2]++, factor[facCnt][1] *= prime[i], tmp /= prime[i];  
        if(factor[facCnt][1] > 1) facCnt++;  
    }  
    if(tmp != 1)  
        factor[facCnt][0] = tmp, factor[facCnt][1] = tmp, factor[facCnt++][2] = 1;  
    return facCnt;  
}  

// hash func for pair
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const { 
        auto hash1 = hash<T1>{}(p.first); auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

int main() {
    string s;
    cin >> s; long long cnt = 0;
    if (s[0] == '?') s[0] = 'D';
    if (s[0]== 'D') cnt++;
    for (int i = 1; i < s.size(); ++i) {
        if (s[i] == 'D') cnt++;
        if (s[i] == 'D' && s[i-1] == 'P') cnt++;
        if (s[i] == '?' && s[i-1] == 'P') {
            s[i] = 'D'; cnt+=2;
        }
        if (s[i] == '?' && s[i-1] == 'D') {
            s[i] = 'D', cnt+=1;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3796
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int x, h, m, s;
		x = scan.nextInt();
		h = x/3600;
		m = x%3600/60;
		s = x%3600%60;
				// 
		
		System.out.println(h+":"+m+":"+s);
	}

}



Measured memory_bytes: 26328
#include<cmath>
#include<cstdio>

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

using namespace std;

const double EPS=1e-9;

int main(){
	const int M=256;

	for(int N;scanf("%d",&N),N;){
		int I[257];
		for(int i=1;i<=N;i++)	scanf("%d",I+i);

		int Smin,Amin,Cmin;
		double Hmin=1e30;
		rep(S,16)rep(A,16)rep(C,16){
			int R[257];	R[0]=S;
			for(int i=1;i<=N;i++)	R[i]=(A*R[i-1]+C)%M;

			int O[256]={};
			for(int i=1;i<=N;i++)	O[(I[i]+R[i])%M]++;

			double H=0;
			rep(i,M) if(O[i]>0) H-=1.*O[i]/N*log(1.*O[i]/N);
			if(H<Hmin-EPS){
				Hmin=H;
				Smin=S,Amin=A,Cmin=C;
			}
		}

		printf("%d %d %d\n",Smin,Amin,Cmin);
	}

	return 0;
}

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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RREP(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define ALL(r) (r).begin(), (r).end()

void Main() {
    int64_t a, b, c, oa, ob, oc, r = 0;
    cin >> a >> b >> c;
    while (a%2==0 && b%2==0 && c%2==0) {
        if (a == b && b == c) {
            cout << -1 << endl;
            return;
        }
        oa = a; a = 0;
        ob = b; b = 0;
        oc = c; c = 0;
        a += ob / 2 + oc / 2;
        b += oa / 2 + oc / 2;
        c += oa / 2 + ob / 2;
        r++;
    }
    cout << r << endl;
}

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


Measured memory_bytes: 3640
# A - Frog 1
from collections import defaultdict


def main():
    N, *H = map(int, open(0).read().split())
    H = [0] + H + [0, 0]
    dp = defaultdict(lambda: 1 << 30)
    dp[1] = 0
    for i, a in enumerate(H[1:N + 1], 1):
        for j, b in enumerate(H[i + 1:i + 3], i + 1):
            dp[j] = min(dp[j], dp[i] + abs(a - b))
    print(dp[N])


if __name__ == "__main__":
    main()


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

using namespace std;

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

int N, M, Q, A, B, C, X, Y, Z;
string s, t;

int dig[10005], used[10005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	dig[0] = 1;
	used[0] = 1;
	Y = 0;
	for (int i = 2; i <= N; ++i){
		int up = 1;
		dig[0]++;
		int cur = 0;
		while (dig[cur] > 9 || dig[cur] > dig[cur+1]+1){
			if (dig[cur] < 10 && used[cur+1] == 0) break;
			used[cur+1] = 1;
			dig[cur] = -1;
			dig[cur+1]++;
			cur++;
		}
		while (cur > 0){
			dig[cur-1] = max(0,dig[cur]-1);
			cur--;
		}
	}
	X = 0;
	for (int i = 10; i >= 0; --i){
		if (X || (dig[i] != 0)){
			X = 1;
			cout << dig[i];
		}
	}
	cout << '\n';
}

Measured memory_bytes: 256
/*https://atcoder.jp/contests/abc149/tasks/abc149_c*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	long long x, n = 1e6 + 1;
	cin >> x;
	if (x == 2)
	{
		cout << "2";
		return 0;
	}
	// int flag = 0;
	for (int i = x; i < n; i++)
	{
		int flag = 0;
		for (int j = 2; j < i; j++)
		{
			// cout << i << " " << j << "->" << i % j << endl;
			if (i % j == 0)
			{
				flag = 1;
				break;
			}
		}
		if (flag == 0)
		{
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 3628
n, q = map(int, input().split())
s = input()

counts = [0] * n
cnt = 0
for i in range(1, n):
    if s[i - 1] == 'A' and s[i] =='C':
        cnt += 1
    counts[i] = cnt

for i in range(q):
    l, r = map(lambda x: int(x) - 1, input().split())
    print(counts[r] - counts[l])

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

#define push(x) vec.push_back(x)
const int MN = 501234;
int a[MN], b[MN], c[MN], n, k;

void sort(int l, int r) {
	if (r - l == 1)
		return;
	int mid = (l + r) / 2;
	sort(l, mid);
	sort(mid, r);
	for (int i = mid - 1, mn = MN; i >= l; i--) {
		mn = min(mn, b[i]);
		c[i] = mn;
	}
	int pl = l,	pr = mid, p = l;
	vector <int> vec;
	while (vec.size() != r - l) {
		if (pl == mid)
			push(b[pr++]);
		else if (pr == r)
			push(b[pl++]);
		else if (b[pr] + k <= c[pl])
			push(b[pr++]);
		else
			push(b[pl++]);
	}
	for (int i = l; i < r; i++)
		b[i] = vec[i - l];
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		b[a[i] - 1] = i;
	sort(0, n);
	for (int i = 0; i < n; i++)
		a[b[i]] = i + 1;
	for (int i = 0; i < n; i++)
		cout << a[i] << ' ';
}

Measured memory_bytes: 9584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p[] = new int[5];
		int j[] = new int[5];
		for(int i = 0; i < 3; i++){
			p[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++){
			j[i] = sc.nextInt();
		}
		
		int pmin = 3000;
		for(int i = 0; i < 3; i++){
			if(pmin > p[i]){
				pmin = p[i];
			}
		}
		int jmin = 3000;
		for(int i = 0; i < 2; i++){
			if(jmin > j[i]){
				jmin = j[i];
			}
		}
		
		int ans = pmin + jmin - 50;
		System.out.println(ans);
	}
}

Measured memory_bytes: 26080
n = int(input())
c = input()
ans, count = 0, 0
for i in range(n-1):
    if c[i] == 'W' and c[i+1] == 'R':
        ans += count+1
        count = 0
    elif c[i] == 'W' and c[i+1] == 'W':
        count += 1

c2 = ''.join(sorted(c))
count2 = 0

for i, j in zip(c, c2):
    if i != j:
        count2 += 1
print(min(ans, count2//2))


Measured memory_bytes: 11380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
 // freopen("input.txt","r",stdin);
#endif

  vector<vector<int> > a(3,vector<int>(3));
  map<int,pair<int,int> > mp;
  for(int i=0;i<3;i++)
  {
    for(int j=0;j<3;j++)
    {
      cin>>a[i][j];
      mp[a[i][j]]={i,j};
    }
  }

  vector<vector<int> > v(3,vector<int>(3,0));

  int n;
  cin>>n;
  for(int i=0;i<n;i++)
    {
      int x;
      cin>>x;
      if(mp.find(x)!=mp.end()){
      pair<int,int> p=mp[x];
      v[p.first][p.second]=1;
      }
    }

  if(v[0][0] && v[0][1] && v[0][2])
    cout<<"Yes"<<endl;
  else if(v[1][0] && v[1][1] && v[1][2])
    cout<<"Yes"<<endl;
  else if(v[2][0] && v[2][1] && v[2][2])
    cout<<"Yes"<<endl;
  else if(v[0][0] && v[1][0] && v[2][0])
    cout<<"Yes"<<endl;
  else if(v[0][1] && v[1][1] && v[2][1])
    cout<<"Yes"<<endl;
  else if(v[0][2] && v[1][2] && v[2][2])
    cout<<"Yes"<<endl;
  else if(v[0][0] && v[1][1] && v[2][2])
    cout<<"Yes"<<endl;
  else if(v[0][2] && v[1][1] && v[2][0])
    cout<<"Yes"<<endl;
  else 
    cout<<"No"<<endl;

  


  return 0;
}

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

void solve() {
    int64_t A, B, N;
    cin >> A >> B >> N;
    auto f = [&](int64_t x) { return A * x / B - A * (x / B); };
    if(B - 1 <= N) cout << f(B - 1) << '\n';
    else cout << f(N) << '\n';
}

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


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N;
    string s;
    cin >> N;
    cin >> s;
    int x = 0;
    int nax = 0;
    for(int i=0; i<N; i++){
        if (s[i] == 'I')x++;
        else if (s[i] == 'D')x--;
        chmax(nax, x);
    }
    cout << nax << endl;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	set <pair<int, int>> s;
	int c = 0;
	for (int i = 0; i < n; i++) {
		auto it = s.upper_bound({-a[i], n}); 
		if (it == s.end()) {
			c++;
			s.emplace(-a[i], c);
		}
		else {
			int color = it->second;
			s.erase(it);
			s.emplace(-a[i], color);
		} 
	}
	cout << c;
	return 0;
}


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

int main() {
	long long int n;
	cin >> n;
	if(n == 2)
	{
		cout << 1 << endl;
		return 0;
	}
	else if(n == 1)
	{
		cout << 0 << endl;
		return 0;
	}
	else
	{
	long long int n2 = (n*(n+1))/2;
	long long int result = n2 - n;
	
	cout << result << endl;
	return 0;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAX_N 200005
using namespace std;

int main()
{
	//freopen("t.txt","r",stdin);
	int n;
	scanf("%d",&n);
    ll a[MAX_N],b[MAX_N];
	for (int i=1;i<=n;i++){
	scanf("%d",&a[i]);
	}
    int j=1; bool check =true;
    for (int i=n;i>=1;i--){
        if (check==true){
           b[j]=a[i];
           check= false;
        }
        else{
            b[n-j+1]= a[i];
            check = true;
            j++;
        }
    }
    for (int i=1;i<=n;i++) cout<<b[i]<<" ";
}


Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <map>
#include <valarray>
#include <tuple>

class Dice {
private:
    std::map<std::tuple<int, int, int>, int> number_map;
    std::map<int, std::valarray<int>> direction_map;
    std::valarray<int> T = {1, 0, 0};
    std::valarray<int> S = {0, 1, 0};
    std::valarray<int> E = {0, 0, 1};
    std::valarray<int> B = {-1, 0, 0};
    std::valarray<int> N = {0, -1, 0};
    std::valarray<int> W = {0, 0, -1};

public:
    Dice(int n1, int n2, int n3, int n4, int n5, int n6) {
        number_map[to_tuple(T)] = n1;
        number_map[to_tuple(S)] = n2;
        number_map[to_tuple(E)] = n3;
        number_map[to_tuple(W)] = n4;
        number_map[to_tuple(N)] = n5;
        number_map[to_tuple(B)] = n6;
        direction_map[n1] = T;
        direction_map[n2] = S;
        direction_map[n3] = E;
        direction_map[n4] = W;
        direction_map[n5] = N;
        direction_map[n6] = B;
    }

    static std::valarray<int> cross(std::valarray<int> d1, std::valarray<int> d2) {
        return d1.cshift(1) * d2.cshift(-1) - d1.cshift(-1) * d2.cshift(1);
    }

    static std::tuple<int, int, int> to_tuple(std::valarray<int> direction) {
        return std::make_tuple(direction[0], direction[1], direction[2]);
    }

    int query(int T_number, int S_number) {
        auto d1 = direction_map[T_number];
        auto d2 = direction_map[S_number];
        auto d3 = cross(d1, d2);
        return number_map[to_tuple(d3)];
    }
};

int main() {
    int n1[6];
    std::cin >> n1[0] >> n1[1] >> n1[2] >> n1[3] >> n1[4] >> n1[5];
    Dice dice1 = Dice(n1[0], n1[1], n1[2], n1[3], n1[4], n1[5]);

    int n2[6];
    std::cin >> n2[0] >> n2[1] >> n2[2] >> n2[3] >> n2[4] >> n2[5];
    Dice dice2 = Dice(n2[0], n2[1], n2[2], n2[3], n2[4], n2[5]);

    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 6; j++) {
            if (dice1.query(n1[i], n1[j]) != dice2.query(n1[i], n1[j])) {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "Yes" << std::endl;
}



Measured memory_bytes: 3184
PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: x,ans
      integer(16) :: num500,num5
      
      read*,x
      
      num500 = x / 500
      x = x - num500 * 500
      
      num5 = x / 5
      
      ans = num500 * 1000 + num5 * 5
      
      print*,ans
      
      
      
      
      
      
      END PROGRAM

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe (fromJust)

main :: IO ()
main = do
  [a, b] <- getInts
  print $ a * b

getInts :: IO [Int]
getInts = fmap (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine


Measured memory_bytes: 3776
num = int(input())
line = list(map(int,input().split()))
dp = [0, abs(line[1] - line[0])]
for i in range(2, num):
  a = dp[-1] + abs(line[i] - line[i - 1])
  b = dp[-2] + abs(line[i] - line[i - 2])
  dp += [min(a,b)]
print(dp[-1])

Measured memory_bytes: 13928
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut done: bool = false;
    while !done {
        let n: u32 = read();
        let x: u32 = read();
        let mut count: u32 = 0;
        if n == 0 && x == 0 {
            done = true;
        } else {
            for a in 1..(n + 1) {
                for b in (a + 1)..(n + 1) {
                    for c in (b + 1)..(n + 1) {
                        if (a + b + c) == x {
                            count += 1;
                        }
                    }
                }
            }
            println!("{}", count);
        }
    }
}



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


int main() 
{
	int n;
	cin >> n;
	int a[n];
	int sum = 0;
	int max = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
		
		max = a[i] > max ? a[i] : max;
	}
	
	cout << sum - max / 2;
	
	return 0;
}

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


int main() {
  string S, T;
  cin >> S >> T;
  int cnt = 0;
  for (int i = 0; i < 3; ++i) {
    if (S[i] == T[i]) {
      ++cnt;
    } 
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  long long n;
  cin>>n;
  int d=1;
  for(int i=1;i<=sqrt(n);i++){
    if(n%i==0){
      d=i;
    }
  }
  int t=n/d;
  int ans=0;
  while(t>0){
    ans++;
    t /= 10;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
N,K = map(int, input().split())
A = list(map(int, input().split()))
S = [0 for i in range(N+1)]
for i in range(1,N+1):
    S[i] = S[i-1] + A[i-1]
cnt = 0
dict1 = {}
        
dict1[0] = 1

for j in range(1,N+1):
    if j-K >= 0:
        dict1[(S[j-K]-j+K)%K] -= 1
    if (S[j]-j)%K in dict1:
        cnt += dict1[(S[j]-j)%K]
        dict1[(S[j]-j)%K] += 1
    else:
        dict1[(S[j]-j)%K] = 1
print (cnt)

Measured memory_bytes: 47632
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n);
	std::vector<std::vector<int>> dp(n + 1, std::vector<int>(3, 0));
	for(int i = 0; i < n; i++) {
		int a, b, c; scanf("%d%d%d", &a, &b, &c);
		dp[i + 1][0] = a + std::max(dp[i][1], dp[i][2]);
		dp[i + 1][1] = b + std::max(dp[i][0], dp[i][2]);
		dp[i + 1][2] = c + std::max(dp[i][0], dp[i][1]);
	}
	printf("%d\n", std::max({dp[n][0], dp[n][1], dp[n][2]}));
	return 0;
}


Measured memory_bytes: 5760
N,K = map(int,input().split())

mod = 10**9+7

ss = 0
ans = [0] * (K+1)

for i in range(K,0,-1):

    now = pow(K // i,N,mod)

    for j in range(2*i,K+1,i):

        now -= ans[j]
        now %= mod

    ans[i] = now % mod
    ss += i * now
    ss %= mod

    
print (ss)


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

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

int main()
{
  char p1[4], p2[4];
  while (cin >> p1 >> p2, p1[0] + p2[0] != '0' + '0'){
    int h = 0, b = 0;
    REP(i, 4){
      REP(j, 4){
        if (p1[i] == p2[j] && i == j) h++;
        else if (p1[i] == p2[j]) b++;
      }
    }
    cout << h << " " << b << endl;
  }
}

Measured memory_bytes: 1140
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
d = b/a
for j in range(n-1):
    o = x[j+1] - x[j]
    if o > d:
        ans += b
    else:
        ans += o * a
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
 	int K, S, count=0;
  	cin >> K >> S;
  
  	for(int i=0; i < K+1; i++){
      for(int j=0 ; j < K+1; j++){
        if(0 <=S-i-j && S-i-j <= K)
          count += 1;
      }
    }

  	cout << count <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll a;
  string b;
  cin >> a >> b;
  string tmp_b;
  rep(i, b.size()) {
    if (b[i] != '.') tmp_b.push_back(b[i]);
  }
  ll c = stoi(tmp_b);
  cout << a * c / 100 << endl;
  return 0;
}

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

using namespace std;

#define ll long long
#define endl "\n"
#define rep(i, n) for(__typeof(n) i = 0; i < n; i++)
#define per(i, n) for(__typeof(n) i = n - 1; i >= 0; i--)
#define loop(i, a, b) for(__typeof(a) i = a; i <= b; i++)
#define set(a, val) memset(a, val, sizeof(a))
#define f first
#define s second
#define all(x) x.begin(), x.end()

const int mod = 1000000007;


int main()
{
    int a, b, k, c = 0;
    cin >> a >> b>> k;

    for(int i = min(a, b); i>= 1; i--)
    {
        if(a % i == 0 && b % i == 0)
            c++;
        if(c == k)
            return cout << i << endl, 0;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String n = scanner.next();
		char[] chars = n.toCharArray();
		chars[0] = chars[0] == '1' ? '9' : '1';
		chars[1] = chars[1] == '1' ? '9' : '1';
		chars[2] = chars[2] == '1' ? '9' : '1';
		System.out.println(chars);
		scanner.close();
	}
}

Measured memory_bytes: 22868
def main():
    L, R = list(map(int, input().split()))
    ans = 2018
    end = min(R+1, L+2019)
    for i in range(L, end-1):
        for j in range(i+1, end):
            ans = min(ans, (i*j)%2019)
    print(ans)

main()


Measured memory_bytes: 38896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#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 chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int h, w;
    cin >> h >> w;
    char c[h][w];
    int sy, sx;
    rep(i, h) rep(j, w) cin >> c[i][j];
    rep(i, h) rep(j, w) {
        if (c[i][j] == '.') continue;
        queue<pii> q;
        q.push({i, j});
        while (!q.empty()) {
            int y = q.front().F;
            int x = q.front().S;
            q.pop();
            rep3(i, -1, 1 + 1) rep3(j, -1, 1 + 1) {
                if (i != 0 && j != 0) continue;
                if (i == 0 && j == 0) continue;
                int ny = y + i;
                int nx = x + j;
                if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
                if (c[ny][nx] == '.') continue;
                c[ny][nx] = '.';
                q.push({ny, nx});
            }
        }
    }
    rep(i, h) rep(j, w) if (c[i][j] == '#') { out("No"); return 0; }
    out("Yes");
    
}


Measured memory_bytes: 256
(defun gen (str1 str2 &optional s)
  (cond ((equal str1 "") s)
    (t (gen (subseq str1 1) (subseq str2 1)
       (concatenate 'string s (subseq str1 0 1)(subseq str2 0 1)))))
  )


(let* ((n (read))
       (s (read-line))
       (str1 (subseq s 0 n))
       (str2 (subseq s (+ n 1))))
      (format t "~A~%" (gen str1 str2)))

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

using namespace std;
typedef long long i64;
typedef long long int lli;

void fast_io(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main(){

	fast_io();
	//code starts here
	
	int k;
	cin >> k;
	
	string s = "";
	for(int i = 0; i < k; i++){
		s += "ACL";
	}
	cout << s << endl;

	return 0;

}



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

int main(){
  int ave=0 ,score;
  for( int i=0 ; i<5 ; i++ ){
    cin >> score;
    if( score < 40 ){
      score = 40;
    }
    ave += score;
  }
  
  cout << ave/5 << endl;
}

Measured memory_bytes: 1160
use std::cmp::max;

// ref. https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        cost: [[usize;3];n]
    }

    let mut dp: Vec<Vec<usize>> = vec![vec![0; 3]; n+100];

    for n_ in 0..n{
        for j in 0..3{
            for k in 0..3{
                if j == k{
                    continue
                }

                dp[n_+1][k] = max(dp[n_+1][k], dp[n_][j] + cost[n_][k]);
            }
        }
    }

    let mut max = 0;
    for i in 0..3{
        max = if dp[n][i] > max {
            dp[n][i]
        }else{
            max
        };
    };
    println!("{:?}", max);
}


Measured memory_bytes: 20732
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
int cost(int num1, int num2) {

	if (num1 > num2)return (num1 - num2)*(num1 - num2);
	else return (num2 - num1)*(num2 - num1);

}
int main() {

	int N, a[105], tmp, ans = INT_MAX;

	cin >> N;
	for (int i = 0; i < N; i++) {

		cin >> a[i];

	}

	for (int i = -100; i <= 100; i++) {
		tmp = 0;

		for (int j = 0; j < N; j++) {

			tmp += cost(a[j], i);

		}
		if (ans > tmp)ans = tmp;

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define int long long

string per(int n) {
    string s;
    if (n == 0) {
        s += '0';
        return s;
    }
    while (n > 0) {
        if (n % 2) s += '1';
        else s += '0';
        n /= 2;
    }
    return s;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    vector<int> vec(n), f(23, 0);
    for (int i = 0; i < n; ++i) cin >> vec[i];
    int l = 0, r = 0, ans = 0;
    while (l < n) {
        if (r == n) {
            ans += r - l;
            l++;
            continue;
        }
        while (true) {
            if (r == n) break;
            string s = per(vec[r]);
            bool flag = true;
            //cout << s << endl;
            for (int i = 0; i < s.size(); ++i) {
                if (s[i] == '1' && f[i] == 1) {
                    flag = false;
                    break;
                }
            }
            if (!flag) break;
            for (int i = 0; i < s.size(); ++i) {
                if (s[i] == '1') f[i] += 1;
            }
            r++;
        }
        //cout << l << " " << r << endl;
        ans += r - l;
        string s = per(vec[l]);
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == '1') f[i]--;
        }
        l++;
    }
    cout << ans;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>

const int LEN = 100005;

typedef struct pp {
    char name[100];
    int t;
} P;

P queue[LEN];

int head, tail, n;

void enqueue(P p) {
    queue[tail] = p;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P p = queue[head];
    head = (head + 1) % LEN;
    return p;
}

int main() {
    int elaps = 0, c;
    int q;
    P p;
    scanf("%d %d", &n, &q);

    for (int i = 1; i <= n; ++i) {
        scanf("%s", queue[i].name);
        scanf("%d", &queue[i].t);
    }

    head = 1;
    tail = n + 1;

    while (head != tail) {
        p = dequeue();
        c = p.t < q ? p.t : q;
        elaps += c;
        p.t -= c;
        if (p.t > 0) {
            enqueue(p);
        } else {
            printf("%s %d\n", p.name, elaps);
        }
    }

    return 0;
}



Measured memory_bytes: 12724
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=gg[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

typedef long long ll;

const int N=2e5+50,P=1e9+7,K=5,oo=0x3f3f3f3f;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }

int n;
vector<int> g[N];
int dfs(int v,int p){
	int res=0;
	for(int d:g[v]){
		if(d!=p){
			int x=dfs(d,v);
			res^=x+1;
		}
	}
	return res;
}

int main(int argc,char *argv[]){
#ifdef CCURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	scanf("%d",&n); 
	rep(i,1,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].pb(v);
		g[v].pb(u); 
	}
	int res=dfs(1,0);
	puts(res!=0?"Alice":"Bob"); 
	return 0;
}

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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}

long long p,c,n,x[100005],v[100005],ma,s,g,d;

int main()
{
	n=read();
	cin>>c;
	for(int i=1; i<=n; ++i){
		cin>>x[i];
		v[i]=read();
	}
	for(int i=1; i<=n; ++i)s+=v[i];
	ma=max(0ll,s-x[n]);
	
	d=s-x[n];
	for(int i=n; i; --i){
		d+=x[i]-x[i-1]-v[i];
		p+=v[i];
		g=max(g,p-(c-x[i]));
		ma=max(ma,d);
		ma=max(ma,d-x[i-1]+g);
	}
	
	for(int i=1; i<=n; ++i)x[i]=c-x[i]; 
	
	s=0;for(int i=1; i<=n; ++i)s+=v[i];
	ma=max(ma,s-x[1]);
	
	d=s-x[1]; p=0; g=0;
	for(int i=1; i<=n; ++i){  //<
		d+=x[i]-x[i+1]-v[i];
		p+=v[i];
		g=max(g,p-(c-x[i]));
		ma=max(ma,d);
		ma=max(ma,d-x[i+1]+g);
	}
	
	printf("%lld\n",ma);
	
}

Measured memory_bytes: 1792
n,k = map(int,input().split())
L = list(map(int,input().split()))
syokou = [0]*n
kousa = [0]*n
for i in range(n):
    cnt = 0
    for j in range(i,n):
        if L[i] > L[j]:
            cnt += 1
    syokou[i] = cnt
for i in range(n):
    cnt = 0
    for j in range(n):
        if L[i] > L[j]:
            cnt += 1
    kousa[i] = cnt
ans = 0
for i in range(n):
    ans += (syokou[i]-kousa[i])*k+(kousa[i]*(k+1)*k//2)
    ans %= (10**9)+7
print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[][] s = new String[h][w];
		String[] alf = new String[26];
		for(char c = 'A' ; c <= 'Z' ; c++) alf[(int)(c - 'A')] = String.valueOf(c);
		for(int i = 0 ; i < h ; i++) {
			for(int j = 0 ; j < w ; j++) {
				s[i][j] = sc.next();
			}
		}
		for(int i = 0 ; i < h ; i++) {
			for(int j = 0 ; j < w ; j++) {
				if(s[i][j].equals("snuke")) {
					System.out.println(alf[j] + (i + 1));
				}
			}
		}
	}
}

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

#define FAST ios_base:: sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ff first
#define ss second
#define mp make_pair
#define FOR(i,a,b) for(ll i=a; i<b ; i++)
typedef long long ll;

ll gcd(ll a, ll b){
	return __gcd(a,b);
}

int main(){
	FAST;
	ll n;	cin >> n;
	ll a[n];
	for(auto &X : a)	cin >> X;
	
	ll dp[n+1][2];
	dp[0][0] = 0;
	dp[0][1] = INT_MIN;
	
	for(ll i=0 ; i<n; i++){
		dp[i+1][0] = max(dp[i][0]+a[i],dp[i][1]-a[i]);
		dp[i+1][1] = max(dp[i][0]-a[i],dp[i][1]+a[i]);
	}
	cout << dp[n][0];
	
}




Measured memory_bytes: 2560
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,k,i;
  cin >> n >> k;
  vector<int> x(n);
  for(i=0;i<n;i++){
    cin >> x[i];
  }
  sort(x.begin(),x.end());
  int ans=0;
  for(i=0;i<k;i++){
    ans+=x[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> A(N), B(N);
  rep(i, N) {
    cin >> A[i];
    B[i] = 0;
  }
  rep(i, N) {
    B[A[i]]++;
  }
  sort(all(B));
  reverse(all(B));
  int ans = 0;
  rep(i, K) {
    ans += B[i];
  }
  cout << N - ans << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 310
using namespace std;
int n, m, ans, map[N][N], sum[N], flag[N], now[N], p;
int main(){
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)scanf("%d", &map[i][j]);
	for(int i=1; i<=m; i++){flag[i]=1; sum[i]=0;} ans=n;
	for(int i=1; i<=n; i++)now[i]=1;
	for(int i=1; i<=n; i++)sum[map[i][1]]++;
	for(int owo=1; owo<=m-1; owo++){
		p=sum[0]=0;
		for(int i=1; i<=m; i++)if(sum[p]<sum[i])p=i;
		ans=min(ans, sum[p]);
		flag[p]=sum[p]=0;
		for(int i=1; i<=n; i++)if(map[i][now[i]]==p){
			while(!flag[map[i][now[i]]])now[i]++;
			sum[map[i][now[i]]]++;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 512
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
using namespace std;


set<int> v;
bool hai(int n){
	if(v.find(n)!=v.end()){
		return false;
	}
	return true;
}

bool valid(int n){
	while(n){
		if(!(hai(n%10))){
			return false;
		}
		n/=10;
	}
	return true;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	
	int n;cin>>n;
	int num[n];
	arrayin(num,n)

	set<int> res;
	for(int i=-100;i<=100;i++){
		int cost=0;
		for(int j=0;j<n;j++){
			cost+=(pow(num[j]-i,2));
		}
		res.insert(cost);
	}
	cout<<*(res.begin())<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define M(a,b) memset(a,b,sizeof a)
#define pb(x) push_back(x)
using namespace std;
const int maxn=1e5+7;
int x,y,n,m;
int main()
{
    int tmp;
    int mix=108,mmx=-108;
    int miy=108,mmy=-108;
    scanf("%d%d%d%d",&n,&m,&x,&y);
    for(int i=1; i<=n; i++)scanf("%d",&tmp),mix=tmp<mix?tmp:mix,mmx=mmx<tmp?tmp:mmx;
    for(int i=1; i<=m; i++)scanf("%d",&tmp),miy=tmp<miy?tmp:miy,mmy=mmy<tmp?tmp:mmy;
    if(mmx>=miy||y<=x)
    {
        printf("War\n");
    }
    else
    {
        if(miy<=x||mmx+1>y)printf("War\n");
        else printf("No War\n");
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<algorithm>
#define ll long long 
#define r(i,n) for(ll i=0;i<n;i++)
#define rp(i,a,b) for(ll i=a;i<b;i++)
#define ret return 
#define elif else if
ll inf=100001;
using namespace std;
int main(){
	while(1){
		ll n,m;cin>>n>>m;
		bool s[n+1],t[n+1];
		r(i,n+1)s[i]=t[i]=0;
		ll a,b;
		r(i,m){
			cin>>a>>b;
			if(a==1){s[b]=1;}
			if(b==n){t[a]=1;}
		}int g=1;
		r(i,n){
			if(s[i]&&t[i]){cout<<"POSSIBLE"<<endl;g=0;break;}
		}if(g)cout<<"IMPOSSIBLE"<<endl;
			ret 0;
	}	
}

Measured memory_bytes: 640
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  int Aflag=0;
  int Bflag=0;

  rep(i,s.size()){
    if(i%2==0){
      if(s.at(i)=='R' ||s.at(i)=='U'|| s.at(i)=='D');
	    else Aflag=1;
    }
    else{
	    if(s.at(i)=='L' ||s.at(i)=='U'|| s.at(i)=='D');
   	    else Bflag=1;
    }
  }
  if(Aflag==1 || Bflag==1)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}
  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for(int (I)=(A);(I)<(B);++(I))
#define ALL(C) (C).begin(),(C).end()
#define INPUT(P) cin>>(P);
#define INPUT2(P1,P2) cin>>(P1)>>(P2);
#define INPUT3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3);
#define INPUTS(I,A,B,V) FOR(I,A,B)cin>>V[I];
#define OUTPUT(P) cout<<P<<endl;
#define OUTPUTS(I,A,B,V) FOR(I,A,B)cout<<V[i]<<endl;
typedef long long ll;
const double INF = 1e9;
int N;
inline void solve()
{
  cin>>N;
  int num[9] = {111,222,333,444,555,666,777,888,999};
  FOR(i,0,9) {
    if (N <= num[i]) {
      cout<<num[i]<<endl;
      break;
    }
  }
}
int main(int argc,char**argv)
{
  BEGIN
  solve();
  END
}


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

int main() {
  int N;
  cin >> N;
  int f=0;
  
  for(int i=N; i >0;){
    f += (i%10);
    i /= 10;
  }
  
  if(N %f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256