akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

string s;
int main() {
	cin >> s;
	const int N = s.size();
	int ans = N;
	REP(i, 1, N) {
		if (s[i] != s[i - 1]) {
			ans = min(ans, (int)max(N - i, i));
		}
	}

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

Measured memory_bytes: 512
A,B=map(int,input().split())
C=[[0 for i in range(100)] for i in range(100)]
for i in range(50,100):
    for j in range(100):
        C[i][j]=1
k=0
for i in range(50):
    for j in range(100):
        if (i*j)%2 ==1:
            if k<A-1:
                C[i][j]=1
                k+=1
            else:
                break
k=0
for i in range(50,100):
    for j in range(100):
        if (i*j)%2 ==1:
            if k<B-1:
                C[i][j]=0
                k+=1
            else:
                break
print(100,100)
for i in range(100):
    st=""
    for j in range(100):
        if C[i][j]==0:
            st+="#"
        else:
            st+="."
    print(st)


Measured memory_bytes: 3188
import random
n, m, k = map(int, input().split())
# n, m, k = random.randint(1, 10**5), random.randint(1, 10**5), random.randint(10**8, 10**9)
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
# a_list = [random.randint(1, 10**3) for i in range(n)]
# b_list = [random.randint(1, 10**3) for i in range(m)]
# print(n,m,k)
# print(a_list[0], b_list[0])
a_sum = [0]
b_sum = [0]
max_a = 0
for i in range(1, max(n+1, m+1)):
    if i < n+1:
        a_sum.append(a_sum[i-1] + a_list[i-1])
        if a_sum[i] <= k:
            max_a = i
    if i < m+1:
        b_sum.append(b_sum[i-1] + b_list[i-1])

ans = 0
j = m
for i in range(0, max_a+1):
    while b_sum[j] > k - a_sum[i]:
        j -= 1
    ans = max(ans, i+j)
        
print(ans)
# print(n+m) 

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

int main()
{
  long n, k;
  cin >> n >> k;
  
  long res = 0;
  for (int i=k; i<=n+1; i++) {
    res += i * (n - i + 1) + 1;
    res %= 1000000007;
  }
  
  cout << res << endl;
}

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

int N;

int main() {
  cin >> N;

  int B = N % 100;
  int A = N / 100;
  
  if (0 < A && A < 13 && 0 < B && B < 13) cout << "AMBIGUOUS" << endl;
  else if (0 < A && A < 13) cout << "MMYY" << endl;
  else if (0 < B && B < 13) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

Pre = sum(A)
for T in range(0,N):
    if A[T]<=B[T]:
        A[T+1] = max(A[T+1]-(B[T]-A[T]),0)
        A[T] = 0
    else:
        A[T] -= B[T]
Aft = sum(A)
print(Pre-Aft)

Measured memory_bytes: 25376
#include<iostream>
using namespace std;
int main()
{
  int n,k,c=0;
  cin>>n>>k;
  int h[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>h[i];
  }
   for(int i=1;i<=n;i++)
  {
    if(h[i]>=k)
    {
      c++;
    }
  }
  cout<<c;
  return 0;
}
  

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, ll X, ll T) {
  ll a = 0;

  while (a * X < N) {
    a++;
  }

  cout << a * T << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  ll X;
  scanf("%lld", &X);
  ll T;
  scanf("%lld", &T);
  solve(N, X, T);
  return 0;
}


Measured memory_bytes: 3720
# -*- coding:utf-8 -*-
import re
S = input()
a = re.sub(r'eraser', '', S)
b = re.sub(r'erase', '', a)
c = re.sub(r'dreamer', '', b)
d = re.sub(r'dream', '', c)
if len(d) == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3700
#include<bits/stdc++.h>
		#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
		#define endl "\n"

		using namespace std;
	
	int main() {	
		int n; cin >> n;
		string y; cin >> y;
		int s = 0;
		int mx = 0;
		for (int i = 0; i < n; ++i) {
			y[i] == 'I' ? ++s : --s;
			mx = max(s, mx);
		}
		cout << mx;
		return 0;
		}
	


Measured memory_bytes: 3580
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A;
	set<int> sset;
	rep(i, 0, 3)
	{
		cin >> A;
		sset.insert(A);
	}

	if (sset.size() == 2)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,m,c,d;
int main(){
	cin>>n>>m;
	for (int i=0;i<m;i++){
		cin>>c;
		d+=c;
	}
	if (d>=n)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m; cin >> n >> m;
    vector<vector<P>> dis(n);
    rep(i,m) {
        int l, r, d; cin >> l >> r >> d;
        l--; r--;
        dis[l].push_back(P(r,d));
        dis[r].push_back(P(l,-d));
    }
    vint value(n,-inf);
    rep(i,n) {
        if (value[i] != -inf) continue;
        value[i] = 0;
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int v = q.front(); q.pop();
            for (P data: dis[v]) {
                int n_v = data.first;
                if (value[n_v] != -inf) {
                    if (value[n_v] != value[v] + data.second) {
                        cout << "No" << endl;
                        return 0;
                    }
                    else continue;
                }
                else {
                    value[n_v] = value[v] + data.second;
                    q.push(n_v);
                }
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 9344
#include <map>
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	map<string, bool> m;
	string s;
	char c ='0';
	for (int i = 0; i < n; i++){
		cin >> s;
		if (c == '0' || s[0] == c){
			if (m[s]){
				printf("No\n");
				return 0;
			}else{
				m[s] = true;
			}
		}else{
			printf("No\n");
			return 0;
		}
		c = s[s.size() - 1];
	}
	printf("Yes\n");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int h, w, n;
  int a[MAX];
  scanf("%d%d%d", &h, &w, &n);
  rep(i, 0, n) scanf("%d", &a[i]);

  int now = 0;
  int line[101];
  rep(hi, 0, h) {
    if ( hi % 2 == 0 ) {
      for ( int wi = 0; wi < w; wi++ ) {
        line[wi] = now+1;
        a[now]--;
        if ( a[now] == 0 ) now++;
      }
    } else {
      for ( int wi = w-1; wi >= 0; wi-- ) {
        line[wi] = now+1;
        a[now]--;
        if ( a[now] == 0 ) now++;
      }
    }
    rep(wi, 0, w) {
      printf("%d ", line[wi]);
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;

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

  reverse(s.begin(), s.end());

  if (s == t) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1005,K=25;
const int MOD=1000000007;
int n,k;
int a[K];
long long C[N][N];
void init(int n=1000)
{
	for(int i=0;i<=n;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=n;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
	}
	return;
}
long long dp[K][N];
int main()
{
	init();
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
		scanf("%d",&a[i]);
	dp[0][0]=1;
	for(int i=1;i<=k;i++)
		for(int j=0;j<=n;j++)
			for(int l=0;l<=min(j,a[i]);l++)
				dp[i][j]=(dp[i][j]+dp[i-1][j-l]*C[n-(j-l)][l]%MOD*C[n-l][a[i]-l]%MOD)%MOD;
	printf("%lld",dp[k][n]);
	return 0;
}

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

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

    int h, m, m1, s;

    s = S % 60;
    m1 = S / 60;
    m = m1 % 60;
    h = m1 / 60;

    cout << h << ":" << m << ":" << s << endl;
    return 0;
}





Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NK = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine(NK[0]%NK[1]==0?0:1);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


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

int main() {
	int n;
	long long a,sum = 0,max = -100000000000, min =100000000000;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		sum += a;
		if (a >= max)max = a;
		if (a <= min)min = a;
	}
	cout << min<<' '<<max<<' '<<sum << endl;
	return 0;
}

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

int main()
{
    unordered_map<string, string> mp{{"Sunny", "Cloudy"}, {"Cloudy", "Rainy"}, {"Rainy", "Sunny"}};
    string s;
    cin >> s;
    cout << mp[s] << endl;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
h_lst = list(map(int,input().split()))

ans_lst = ["N"]*n

for i in range(m):
    a,b = map(int,input().split())
    ha = h_lst[a-1]
    hb = h_lst[b-1]

    if ha > hb:
        if ans_lst[a-1] != "F":
            ans_lst[a-1] = "T"
        ans_lst[b-1] = "F"
    elif ha < hb:
        if ans_lst[b-1] != "F":
            ans_lst[b-1] = "T"
        ans_lst[a-1] = "F"
    elif ha == hb:
        ans_lst[a-1] = "F"
        ans_lst[b-1] = "F"
        
cnt = 0
for moji in ans_lst:
    if moji == "N" or moji == "T":
        cnt += 1
print(cnt)

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

namespace acronym5_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            Console.WriteLine(input[0][0].ToString().ToUpper() + input[1][0].ToString().ToUpper() + input[2][0].ToString().ToUpper());
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b;
    if(a%2!=0&&b%2!=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3588
x,y,z,k = map(int, input().split())
a = sorted(list(map(int, input().split())),reverse=True)
b = sorted(list(map(int, input().split())),reverse=True)
c = sorted(list(map(int, input().split())),reverse=True)

ans = []
for i in range (len(a)):
    for j in range (len(b)):
        if (i+1)*(j+1)>k: break
        for u in range (len(c)):
            if (i+1)*(j+1)*(u+1)>k: break
            ans.append(a[i] + b[j] + c[u])
rans = sorted(ans,reverse = True)
for i in range(k):
    print (rans[i])


Measured memory_bytes: 9536
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = 1e9 + 5;

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> arr(n);
	vector<int> dp(n);
	int ans = INF;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}

	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		if (i <= k) {
			dp[i] = abs(arr[0] - arr[i]);
			continue;
		}

		for (int j = 1; j <= k; j++) {
			ans = min(dp[i - j] + abs(arr[i - j] - arr[i]), ans);
		}
		dp[i] = ans;
		ans = INF;
	}

	cout << dp[n-1];
}


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

	/*
	int t;
	cin >> t;
	while (t) {
		solve();
		cout << "\n";
		t--;
	}
	*/

}



Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <cstdlib>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 1000010
#define INF (1000000050)

typedef set< pair<int,int> >::iterator It;
int nextscore[MAX_N];
set< pair<int,int> > seg[MAX_N];

void add(int x,int y,int score){
	//cout << x << "," << y << "," << score << endl;
	while(x<MAX_N){
		It it1 = --seg[x].lower_bound(make_pair(y+1,-INF));
		It it2 = seg[x].lower_bound(make_pair(y+1,-INF));
		
		if( it1->first <= y && it1->second >= score ){
			x += x & -x;
			continue;
		}
		while( it2->first != INF && it2->second <= score ){
			seg[x].erase(it2++);
		}
		seg[x].insert(make_pair(y,score));
		x += x & -x;
	}
}
int get(int x,int y){
	//cout << "(" << x << "," << y << ")" << endl;
	int maximum = 0;
	while(x>0){
		It it = --seg[x].lower_bound(make_pair(y+1,-INF));
		
		
		/*
		It	 it = seg[x].begin();
		while( it != seg[x].end() ){
			if( it->first <= y ){
				maximum = max(maximum,it->second);
			}
			it++;
		}
		*/
		//cout << " (" << it->first << "," << it->second << ")" << endl;
		maximum = max(maximum,it->second);
		x -= x & -x;
	}
	return maximum;
}


int aa, bb, C = ~(1<<31), M = (1<<16)-1;

int r() {
	aa = 36969 * (aa & M) + (aa >> 16);
	bb = 18000 * (bb & M) + (bb >> 16);
	return (C & ((aa << 16) + bb)) % 1000000;
}

vector< pair<int, pair<int,int> >  > inp;

int main(){
	for(int i = 0 ; i < MAX_N ; i++){
		seg[i].insert(make_pair(INF,INF));
		seg[i].insert(make_pair(-INF,0));
	}
	int m,n;
	while(	cin >> m >> n >> aa >> bb && m+n ){
		inp.clear();
		for(int i = 0 ; i < MAX_N ; i++){
			if( seg[i].size() != 2 ){
				seg[i].clear();
				seg[i].insert(make_pair(INF,INF));
				seg[i].insert(make_pair(-INF,0));
			}
		}
		
		vector<int> ux;
		for(int i = 0 ; i < m ; i++){
			int a,b,c;
			scanf("%d%d%d",&a,&b,&c);
			a++;
			b++;
			c++;
			inp.push_back(make_pair(c,make_pair(a,b)));
		}
		for(int i = 0 ; i < n ; i++){
			int a,b,c;
			a=r()+1;
			b=r()+1;
			c=r()+1;
			inp.push_back(make_pair(c,make_pair(a,b)));
		}
		sort(inp.begin(),inp.end());
		int res = 0;
		for(int i = 0 ; i < inp.size() ; ){
			
			int j = i;
			while( j < inp.size() && inp[i].first == inp[j].first ) j++;
			for(int k = i ; k < j ; k++){
				int a = inp[k].second.first;
				int b = inp[k].second.second;
				nextscore[k] = get(a-1,b-1) + 1;
				res = max( res , nextscore[k] );
				//cout << k << ": " << inp[k].first << " " << inp[k].second.first << " " << inp[k].second.second << " " <<  get(a-1,b-1) <<  endl;
			}
			for(int k = i ; k < j ; k++){
				int a = inp[k].second.first;
				int b = inp[k].second.second;
				add(a,b,nextscore[k]);
			}
			i = j;
		}
		cout << res << endl;
		//return 0;
	}
	
}

Measured memory_bytes: 196240
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,W;
    cin >> n >> W;
    vector<ll> v(n);
    vector<ll> w(n);
    for(i = 0;i < n;++i){
        cin >> v.at(i) >> w.at(i);
    }
    
    vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
    for(i = 1;i <= n;++i){
        rep(j, W+1){
            if(j < w.at(i-1)) dp.at(i).at(j) = dp.at(i-1).at(j);
            else dp.at(i).at(j) = max({dp.at(i-1).at(j), dp.at(i-1).at(j - w.at(i-1)) + v.at(i-1), dp.at(i).at(j - w.at(i-1)) + v.at(i-1)});
        }
    }
    
    cout << dp.at(n).at(W) << endl;
    return 0;
}


Measured memory_bytes: 10808
#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;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n) { cin >> a[i]; --a[i]; }
  rep(i, n) { cin >> b[i]; }
  rep(i, n-1) { cin >> c[i]; }
    
  int ans = 0;
  int prev_index = -100;
  rep(i, n) {
    int index = a[i];
    ans += b[index];
    if (prev_index + 1 == index) {
      ans += c[prev_index];
    }
    prev_index = index;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗, int 2*10^9

int main() {
  int N, a = 0;
  ci(N);
  ve<int> P(N);
  rep(i, N){
    ci(P.at(i));
  }
  int b = 100000000;
  rep(i, N){
    if(P.at(i) < b){
      b = P.at(i);
      a++;
    }
  }
  co(a);
}

Measured memory_bytes: 1024
def main():
  X,N = list(map(int, input().split()))
  P = list(map(int, input().split()))
  #allowed elements
  Q = set([i for i in range(0,101+1)])
  for p in P:
    Q.remove(p)
  Q = sorted(Q)
  # distance from X
  D = [abs(q-X) for q in Q]
  # find smallest minimizer
  minD = min(D)
  for d,q in zip(D,Q):
    if d==minD:
      break
  print(q)
    
if __name__=='__main__':
  main()


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

int main() {
  int A,B;
  cin>>A>>B;
  if(A>=13){
    cout<<B<< endl;
  }
  if(6<=A&&A<=12){
    cout<<B/2<< endl;
  }
  if(A<=5){
    cout<<"0"<< endl;
  }
}

Measured memory_bytes: 764
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
  //INPUT
  llint N,K,Q;
  cin >> N >> K >> Q;
  vector<llint> B(N);
  llint buf;
  rep(i,0,Q) {
    cin >> buf;
    B[buf-1]++;
  }
  // vector<llint> A(Q);
  // rep(i,0,Q) {
  //   cin >> A[i];
  // }

  //SOLVE
  vector<string> ans(N);

  rep(i,0,N) {
    if ((K-Q+B[i]) > 0) {
      ans[i] = "Yes";
    } else {
      ans[i] = "No";
    }
  }

  //OUTPUT
  rep(i,0,N) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;

void solve(){
    int n,m;
    cin >> n >> m;

    vector<pii>a(m);
    rep(i,0,m) { cin >> a[i].first >> a[i].second; }
    vector<pii>b = a;
    sort(all(b));
    /*rep(i,0,m){
    	cout << b[i].first << " " << b[i].second << "\n";
    }*/
    int prev = b[0].first,cnt = 1;
    map<pii,pair<string,string>>ma;
    rep(i,0,m){
    	if(prev != b[i].first) { cnt = 1; prev = b[i].first; }
    	ma[ {b[i].first,b[i].second} ] = make_pair(to_string(b[i].first),to_string(cnt));
    	++cnt;
    }
    rep(i,0,m){
    	for(int j=0;j < 6-(ma[ {a[i].first,a[i].second} ].first).size();++j) cout << "0";
    	cout << ma[ {a[i].first,a[i].second} ].first;
    	for(int j=0;j < 6-ma[ {a[i].first,a[i].second} ].second.size();++j) cout << "0";
    	cout << ma[ {a[i].first,a[i].second} ].second << "\n";
    }
}

int main(){
    
    fast_io;
    // cin.exceptions(cin.failbit);
    
    solve();
    
    
    cpuTime();
return 0;
}


/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/

Measured memory_bytes: 18688
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> a >> b >> c >> k;
    sum = min(a,k);
    k -= sum;
    x = min(k,b);
    k -= x;
    sum -= k;
    cout << sum;

    return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>

#include <vector>
#include<functional>
using namespace std;
const int INF = 1<<30;



using Index = int;
template<typename Data>
class SegmentTree{
  public:
    int size;
    vector<Data> data;
    SegmentTree(int n){
        size = n;
        n = 1;
        while(n < size) n *= 2;
        size = n;
        data.resize( 2 * n - 1, 0);
    }
    // Array[i] += val
    void add(Index i, Data val){
        i += size - 1;
        while(i){ // ??¨????????£?????????
            data[i] += val;
            i = (i - 1) / 2;
        }
        data[i] += val;
    }
    // sum of [a, b)
    Data sum(int a, int b){
        return sum(a, b, 0, 0, size);
    }
    void debug_print(){
        int len = 1;
        Index i = 0;
        cerr << "** SegTree **" << endl;
        while(i < data.size()){
            for(int j = 0;j < len and i < data.size(); j++,i++){
                cerr << " " << data[i];
            }
            cerr << endl;
            len *= 2;
        }
        cerr << endl;
    }
  private:
    //[a,b)???sum, i???????????´???, [l,r)???i???????????????
    Data sum(Index a, Index b, Index i, Index l, Index r){
        if( r <= a or b <= l ) return 0; // out range
        else if( a <= l and r <= b ) return data[i]; // in range
        else { // intersect
            Index lc = i * 2 + 1;
            Index rc = i * 2 + 2;
            Index m = (l + r) / 2;
            return sum(a, b, lc, l, m) + sum(a, b, rc, m, r);
        }
    }
};

int main(){
    int n, q; cin >> n >> q;
    SegmentTree<long long> st(n+1);
    for(int i = 0; i < q; i++){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0){
            st.add(x, y);
            //st.debug_print();
        } else {
            cout << st.sum(x, y+1) << endl;
        }
    }
    return 0;
}

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

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

    string keyence = "keyence";
    int head = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (head >= keyence.size() || S.at(i) != keyence.at(head))
        {
            break;
        }
        head++;
    }
    int tail = keyence.size() - 1;
    for (int i = S.size() - 1; i >= 0; i--)
    {
        if (tail < 0 || S.at(i) != keyence.at(tail))
        {
            break;
        }
        tail--;
    }
    if (tail < head)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

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

int main() {
  int n; cin >>n;
  int ret = 0;

  for (int i = 1; i <= n; i++) {
    int a; cin >>a;
    if (i%2==1 && a%2==1) ret++;
  }

  cout << ret << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    
    vector<int> vec(4);
    for (int i = 0; i < 4; i++) {
        vec.at(i) = s[i] - '0';
    }
    
    int a = vec.at(0);
    int b = vec.at(1);
    int c = vec.at(2);
    int d = vec.at(3);
    
    if (a + b + c + d == 7) {
        cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
        return 0;
    } else if (a + b + c - d == 7) {
        cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
        return 0;
    } else if (a + b - c + d == 7) {
        cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
        return 0;
    } else if (a + b - c - d == 7) {
        cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
        return 0;
    } else if (a - b + c + d == 7) {
        cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
        return 0;
    } else if (a - b + c - d == 7) {
        cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
        return 0;
    } else if (a - b - c + d == 7) {
        cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
        return 0;
    } else if (a - b - c - d == 7) {
        cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
        return 0;
    }
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10^^9+7L;
long[10^^5*2+50] F, RF;

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long comb(N)(N n, N k)
{
    auto n_b = F[n];    // n!
    auto nk_b = RF[n-k]; // 1 / (n-k)!
    auto k_b = RF[k];    // 1 / k!

    auto nk_b_k_b = (nk_b * k_b) % P; // 1 / (n-k)!k!

    return (n_b * nk_b_k_b) % P;  // n! / (n-k)!k!
}

long[200001] DA, DB, DC;

void main()
{
    init();
    auto nabc = readln.split.to!(int[]);
    auto N = nabc[0];
    auto A = nabc[1];
    auto B = nabc[2];
    auto C = nabc[3];

    long RC = 1, rc = 100 - C, X = P-2;
    while (X) {
        if (X%2 == 1) RC = (RC * rc) % P;
        rc = rc^^2 % P;
        X /= 2;
    }

    foreach (n; 0..N*2+1) {
        if (n == 0) {
            DA[n] = DB[n] = DC[n] = 1;
        } else if (n == 1) {
            DA[n] = A;
            DB[n] = B;
            DC[n] = RC;
        } else {
            DA[n] = (DA[n-1] * A) % P;
            DB[n] = (DB[n-1] * B) % P;
            DC[n] = (DC[n-1] * RC) % P;
        }
    }

    long r;
    foreach (M; N..N*2) {
        long t = (DA[N] * DB[M-N]) % P;
        long s = (DA[M-N] * DB[N]) % P;
        t = (t + s) % P;
        t = (t * M) % P;
        t = (t * DC[M+1]) % P;
        t = (t * 100) % P;
        t = (t * comb(M-1, N-1)) % P;
        r = (t + r) % P;
    }
    writeln(r);
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  vector<vector<char>> ans(h, vector<char>(w, '#'));
  rep(i, h) rep(j, w) {
    if(s[i][j] == '#') continue;
    int c = 0;
    rep(k, 8) {
      int ni = i+di[k], nj = j+dj[k];
      if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if(s[ni][nj] == '#') ++c;
    }
    ans[i][j] = '0'+c;
  }
  rep(i, h) {
    rep(j, w) cout << ans[i][j];
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    string s; cin >> s;
    if(s == "Sunny"){cout << "Cloudy" << "\n";}
    else if(s == "Cloudy"){cout << "Rainy" << "\n";}
    else{cout << "Sunny" << "\n";}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
set<long long> mp;
int main(){
long long n,a,b,temp;
cin>>n>>a>>b;
int i,j;
if(a>b||(n<=1&&a<b))
printf("0");
else if(a==b)
printf("1");
else {
	printf("%lld",(n-2)*(b-a)+1);
}



return 0;
}



Measured memory_bytes: 384
/*
ID: amagica1
TASK: ariprog
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define NINF -INF
#define mp make_pair
#define boost() cin.tie(0); cin.sync_with_stdio(0)
#define For(i, a, b) for(int i=a; i<b; i++)
#define FOR(i, a, b) for(int i=a; i<=b; i++)
#define Rev(i, a, b) for(int i=a; i>b; i--)
#define REV(i, a, b) for(int i=a; i>=b; i--)
typedef long long ll;
typedef long double ld;
typedef int64_t l;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int MAXN = 1000005;
ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
int main() {
    //-----------FILE------------//
    // freopen("ariprog.in", "r", stdin);
    // freopen("ariprog.out", "w", stdout);
    //----------------------------//
    ll N; scanf("%lld", &N); ll cnt=0;
    if(N % 2 != 0) {printf("0\n"); return 0;}
    for(ll i=5; N/i >= 1; i*=5) {
        cnt += 1LL*N/(i*2L);
    }
    printf("%lld", cnt);
}
// 1000000000000000000
// 999999999999999999

// 124999999999999995
// 124999999999999977

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
            System.out.println("Possible");
        } else {
            System.out.println("Impossible");
        }
    }
}


Measured memory_bytes: 21588
// Problem : C - Vacation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

int n;
vi a,b,c;

int dp[N][3];

int f(int i, int last){
    if(i == n) return 0;
    int &ret = dp[i][last];
    if(~ret) return ret;
    ret = 0;
    if(last != 0) ret = max(ret,f(i+1,0)+a[i]);
    if(last != 1) ret = max(ret,f(i+1,1)+b[i]);
    if(last != 2) ret = max(ret,f(i+1,2)+c[i]);
    return ret;
}

void solve(){
    cin>>n;
    a.resize(n);
    b.resize(n);
    c.resize(n);
    for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
    memset(dp,-1,sizeof(dp));
    cout<<max(f(0,0),max(f(0,1),f(0,2)));
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 12684
#include<stdio.h>
#include<stdlib.h>
#include <string.h>

int main(void)
{
    char s[11];
    int ans=1,i,length,Cnum=0,Cindex=-1;

    scanf("%s",s);

    length=strlen(s);

    if(s[0]!='A') ans=0;

    for ( i = 2; i <= length-2; i++)
    {
        if(s[i]=='C')
        {
            Cnum++;
            Cindex=i;
        }
    }
    if(Cnum!=1) ans=0;

    for ( i = 0; i < length; i++)
    {
        if(i!=0&&i!=Cindex&&'A'<=s[i]&&s[i]<='Z') ans=0;
    }

    if(ans==1) printf("AC");
    else printf("WA");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
  
int main(){
    int n, m; cin >> n >> m;
    if(m == 1){
        cout << 0 << endl;
        return 0;
    }
    vector<ll> x(m);
    rep(i, m) cin >> x[i];
    sort(x.begin(), x.end());
    vector<ll> y(m - 1);
    ll sum = 0;
    rep(i, m - 1){
        y[i] = abs(x[i + 1] - x[i]);
        sum += y[i];
    }
    ll l = min(n - 1, m - 1);
    sort(y.begin(), y.end(), greater<>());
    rep(i, l){
        sum -= y[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

  int n;
  cin >> n;
  int x[n], y[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
  }

  double sum = 0;
  int count = 0;
  do {
    for (int i = 0; i + 1 < n; i++) {
      double dx = x[p[i + 1]] - x[p[i]];
      double dy = y[p[i + 1]] - y[p[i]];
      sum += sqrt(dx * dx + dy * dy);
    }
    ++count;
  } while (next_permutation(p.begin(), p.end()));

  double ans = sum / count;

  printf("%.7lf\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
    int n;
    cin >> n;
    string s;
    int cnt[4] = {0,0,0,0};
    rep(i, n) {
        cin >> s;
        if (s == "AC") cnt[0]++;
        else if (s == "WA") cnt[1]++;
        else if (s == "TLE") cnt[2]++;
        else if (s == "RE") cnt[3]++;
    }

    string jud[4] = {"AC", "WA", "TLE", "RE"};
    rep(i, 4) cout << jud[i] << " x " << cnt[i] << endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()

const ll Mod = 998244353;

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

    double l; cin>>l;
    double ans = (l*l*l)/27.0;
    cout<<fixed<<setprecision(12)<<ans<<"\n";
    
    return 0;
}

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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

int yo(int x)
{
    int ret=x*x*x*x*x;
    return ret;
}
 main()

{
    fast
    int x;
    cin>>x;
    for(int a=-500;a<=500;a++)
    {
        for(int b=-500;b<=500;b++)
        {
            int chk=yo(a)-yo(b);
            if(chk==x)
            {
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }




    return 0;

}













Measured memory_bytes: 3644