akhauriyash/Code-Regression huggingface dataset:
s = input()

a = [0] * len(s)
b = [0] * len(s)
c = [0] * len(s)
q = 0
m = 10**9 + 7

if s[0] == "A":
    a[0] = 1
elif s[0] == "?":
    a[0] = 1
    q = 1

for i in range(1, len(s)):
    if s[i] == "A":
        a[i] = (a[i - 1] + pow(3, q, m)) % m
        b[i] = b[i - 1] % m
        c[i] = c[i - 1] % m
    elif s[i] == "B":
        a[i] = a[i - 1] % m
        b[i] = (b[i - 1] + a[i - 1]) % m
        c[i] = c[i - 1] % m
    elif s[i] == "C":
        a[i] = a[i - 1] % m
        b[i] = b[i - 1] % m
        c[i] = (c[i - 1] + b[i - 1]) % m
    else:
        a[i] = (3 * a[i - 1] + pow(3, q, m)) % m
        b[i] = (3 * b[i - 1] + a[i - 1]) % m
        c[i] = (3 * c[i - 1] + b[i - 1]) % m
        q += 1
        
print(c[len(s) - 1] % m)

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

int main(){
  int n, ret=0;
  cin >> n;
  for(int i=105; i<=n; i+=2){
    int c=1;
    for(int j=1; j<=i/2; j++){
      if(i%j==0)c++;
    }
    if(c==8)ret++;
  }
  cout << ret;
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		String S = next();
		int indexOf = S.indexOf("A");
		if(indexOf > 0)S = S.substring(indexOf, S.length());
		S += "A";
		char[] C = S.toCharArray();
		int num_A = 0;
		long res = 0;
		int Clen = C.length;
		for(int i=0;i<Clen;i++) {
			if(C[i]=='A') num_A++;
			else if(C[i]=='B'&&C[i+1]=='C') {
				res += num_A;
				i++;
			}
			else num_A = 0;
		}
		out.println(res);
	}
	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}

}

Measured memory_bytes: 28792
// https://atcoder.jp/contests/abc176/tasks/abc176_c

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
	ll n;
	cin >> n;
	stack<ll> st;
	ll num;
	cin >> num;
	--n;
	st.push(num);
	ll stool = 0;
	while (n--) {
		cin >> num;
		if (st.top() > num) {
			stool += (st.top()-num);
		} else {
			st.push(num);
		}
	}
	cout << stool << endl;
	return 0;
}


Measured memory_bytes: 5084
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100001];
int dp[100001];
int graph_1dp(int si,int v,int *dp){
    if(dp[si]>-1) return dp[si];
    bool leaf=false;
    int best=0;
    for(int child:graph[si]){
        leaf=true;
        best=max(best,graph_1dp(child,v,dp));
    }
    return leaf? dp[si]=1+best:dp[si]=0;
}
int main() {
    int v,e;
    cin>>v>>e;
    for(int i=0;i<e;i++){
        int a,b;
        cin>>a>>b;
        graph[a-1].push_back(b-1);
    }
    memset(dp,-1,sizeof(dp));
    int ans=0;
    for(int i=0;i<v;i++){
        ans=max(ans,graph_1dp(i,v,dp));
    }
    cout<<ans<<endl;
}


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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int x=(A-1)/D,y=(C-1)/B;
  if(y<=x){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll maxSubArraySum(int a[], int size)
{
         ll max_so_far = 0, max_ending_here = 0;
   for (int i = 0; i < size; i++)
   {
       max_ending_here = max_ending_here + a[i];
       if (max_ending_here < 0)
           max_ending_here = 0;

       /* Do not compare for all elements. Compare only
          when  max_ending_here > 0 */
       else if (max_so_far < max_ending_here)
           max_so_far = max_ending_here;
   }
                return max_so_far;
}
int main()
{
	int n,k;
	cin>>n>>k;
	ll arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n,greater<ll>());
	ll sum=0;
	for(int i=k;i<n;i++)
	{
		sum=sum+arr[i];
	}
	cout<<sum<<endl;
}



Measured memory_bytes: 1792
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n;
  ll a[110];
  ll x;
  std::cin >> n >> x;
  for(int i=0; i<n; i++) std::cin >> a[i];

  sort(a,a+n);
  int cnt=0,i=0;
  while(x>0 && i<n){
    x-=a[i];
    cnt++;
    i++;
  }

  if(x==0)std::cout << cnt << '\n';
  else if(x>0)std::cout << cnt-1 << '\n';
  else std::cout << i-1 << '\n';

  return 0;
}


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

ll nsqrt(ll N)
{
        if(N == 0) return 0;
    ll x = N;
    ll y = floor((floor(N/x) + x)/2);
    while(y < x) {
        x = y;
        y = floor((floor(N/x) + x)/2);
    }
    return x;
}

void init_Qn(vector<ll> &Qn)
{
        int n = Qn.size();
        for(int i = 0; i < n; ++i) {
                Qn[i*i % n] = 1;
        }
}

bool square_detection(ll N)
{
        vector<ll> Q64(64, 0);
        vector<ll> Q63(63, 0);
        vector<ll> Q65(65, 0);
        vector<ll> Q11(11, 0);
        init_Qn(Q64);
        init_Qn(Q63);
        init_Qn(Q65);
        init_Qn(Q11);
        if(Q64[N%64] == 0) return false;
        ll r = N % 63*65*11;
        //if(Q63[N%63] == 0 || Q65[N%65] == 0 || Q11[N%11] == 0) return false;
        if(Q63[r%63] == 0) return false;
        //N %= 65*11;
        if(Q65[r%65] == 0) return false;
        r %= 11;
        if(Q11[r] == 0) return false;
        return nsqrt(N)*nsqrt(N) == N;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    if(square_detection(8*n+1)) {
        int K = (1+nsqrt(8*n+1))/2;
        cout << "Yes" << endl;
        cout << K << endl;
        vector<vector<int>> ans(K, vector<int>(K-1, 0));
        int pos = K;
        for(int i = 0; i <K-1; ++i) {
            ans[0][i] = i+1;
        }
        for(int i = 1; i < K; ++i) {
            for(int j = 0; j < i; ++j) {
                ans[i][j] = ans[j][i-1];
            }
            for(int j = i; j < K-1; ++j) {
                ans[i][j] = pos + j-i;
            }
            pos += K-1-i;
        }
        for(int i = 0; i < K; ++i) {
            cout << K-1 << " ";
            for(int j = 0; j < K-1; ++j) {
                cout << ans[i][j] << " ";
            }
            cout << endl;
        }
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, K;
	cat M;
	cin >> N >> K >> M;
	vector< vector<cat> > cnt_fixv(N+1, vector<cat>(N+1, 0));
	cnt_fixv[0][0] = 1;
	for(int i = 1; i <= N; i++) for(int j = 0; j <= i; j++) {
		cnt_fixv[i][j] = cnt_fixv[i-1][j];
		if(j > 0) cnt_fixv[i][j] += cnt_fixv[i-1][j-1] * (i-j+1);
		cnt_fixv[i][j] %= M;
	}
	vector< vector<cat> > ans(N+1, vector<cat>(K+1, 0));
	ans[0][0] = 1;
	for(int k = 1; k <= K; k++) for(int i = 0; i <= N; i++) {
		for(int j = 0; j <= i; j++) ans[i][k] += (ans[i-j][k-1] * cnt_fixv[i][j]) % M;
		ans[i][k] %= M;
	}
	cout << ans[N][K] << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	lint N;
	cin >> N;
	vector<lint>H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	vector<lint>cnt(N + 10);
	lint cnti = 0;
	lint cnt2 = 0;
	for (int i = 1; i < N; i++) {
		if (H[i] <= H[i - 1]) {
			cnti++;
		}
		else {
			cnt[cnt2] = cnti;
			cnt2++;
			cnti = 0;
		}
	}
	cnt[N + 9] = cnti;
	sort(cnt.rbegin(), cnt.rend());
	cout << cnt[0] << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stack>

using namespace std;

int main()
{
    int N; cin >> N;
    int Q; cin >> Q;
    
    stack<int> S[N];
    
    for(int i = 0; i < Q; ++i)
    {
        int Command; cin >> Command;
        int t; cin >> t;
        
        if(Command == 0)
        {
            int val; cin >> val;
            S[t].push(val);    
            
        }
        else if(Command == 1)
        {
            if(S[t].size())
                cout << S[t].top() << endl;
        }
        else if(Command == 2)
        {
            if(S[t].size())
                S[t].pop();
        }
        
    }
    
    return 0;
}


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

int main() {
    int N, K, cnt = 0;
    char s[100001];
    scanf("%d%d %s", &N, &K, s);
    for (int i=1;s[i]!='\0';++i)
        if (s[i-1] == s[i]) cnt++;
    printf("%d", min(cnt + 2 * K, N-1));
}

Measured memory_bytes: 384
n,m,l=map(int,input().split())
a=list()
b=list()
for i in range(n):
    a.append(list(map(int,input().split())))

for i in range(m):
    b.append(list(map(int,input().split())))

for i in range(n):
    li = []
    for j in range(l):
        su = 0
        for k in range(m):
            su += a[i][k] * b[k][j]
        li.append(su)
    print(" ".join(list(map(str, li))))



Measured memory_bytes: 6248
#include<iostream>

using namespace std;

int main(){
  int n,a[2][100]{0},ans=0;
  cin >> n;
  for (int i=0;i<2*n;i++){
    cin >> a[i/n][i%n];
  }
  for (int i=1;i<n;i++){
    a[0][i]+=a[0][i-1];
    a[1][n-i-1]+=a[1][n-i];
  }
  for (int i=0;i<n;i++){
    if (ans<a[0][i]+a[1][i])ans=a[0][i]+a[1][i];
  }
  cout << ans << endl;
  return 0;
}


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

if __name__ == '__main__':
  N = int(input())
  A=[]
  B=[]
  for _ in range(N):
    s, n = input().split()
    A.append((s, int(n)))
    B.append((s, int(n)))

  def swap(A, i, j):
    tmp = A[i]
    A[i] = A[j]
    A[j] = tmp
  
  def partition(A, p, r):
    x = A[r][1]
    i = p - 1
    for j in range(p, r):
      if A[j][1] <= x:
        i += 1
        swap(A, i, j)
    swap(A, i + 1, r)
    return i + 1
  
  #r含む
  def quicksort(A, p, r):
    if p < r:
      q = partition(A, p, r)
      quicksort(A, p, q - 1)
      quicksort(A, q + 1, r)

  def merge(B, left, middle, right):
    n1 = middle - left
    n2 = right - middle
    L1=[('a', 0)]*n1
    L2=[('a', 0)]*n2
    for i in range(n1):
      L1[i] = B[left + i]
    for j in range(n2):
      L2[j] = B[middle + j]
    L1.append(('z', 10**9+1))
    L2.append(('z', 10**9+1))
    #print(L1)
    #print(L2)
    i = 0
    j = 0
    for k in range(left, right):
      if L1[i][1] <= L2[j][1]:
        B[k] = L1[i]
        i += 1
      else:
        B[k] = L2[j]
        j += 1

  
  def mergeSort(B, left, right):
    if left + 1 < right:
      middle = (left + right) // 2
      mergeSort(B, left, middle)
      mergeSort(B, middle, right)
      merge(B, left, middle, right)

  
  quicksort(A, 0, N - 1)
  mergeSort(B, 0, N)
  print('Stable' if A==B else 'Not stable')
  for a in A:
    print(a[0] + ' ' + str(a[1]))



Measured memory_bytes: 27072
#include<iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a==b){
        cout << "Draw" << endl;
    }
    else if(a==1){
        cout << "Alice" << endl;
    }
    else if(b==1){
        cout << "Bob" << endl;
    }
    else if(a>b){
        cout << "Alice" << endl; 
    }
    else{
        cout << "Bob" << endl;
    }
}

Measured memory_bytes: 256
chomp (my $n = <STDIN>);
my $gcd = sub {
  my ($x, $y) = @_;
  while ($y) {
    my $r = $x % $y;
    $r += $y if $r < 0;
    $x = $y;
    $y = $r;
  }
  return $x;
};
my $lcm = sub {
  my ($x, $y) = @_;
  $x / $gcd->($x, $y) * $y;
};
my $ans = 1;
for my $i (1..$n) {
  chomp ($t = <STDIN>);
  $ans = $lcm->($ans, $t);
}
print "$ans\n";

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}

template<class Type>
Type solve(Type res = Type()){
    ll H; cin >> H;

    res = 1;
    while(H>1){
        res = 2*res + 1;
        H>>=1;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

ll getMode(vector<ll> &v) {
  vector<ll> cnt(1e5 + 11);
  for (ll i = 0; i < v.size(); i++) {
    cnt[v[i]]++;
  }
  auto max_iterator = max_element(cnt.begin(), cnt.end());
  return distance(cnt.begin(), max_iterator);
}

ll get2ndMode(vector<ll> &v, ll mode) {
  vector<ll> cnt(1e5 + 11);
  for (ll i = 0; i < v.size(); i++) {
    if (v[i] == mode) continue;
    cnt[v[i]]++;
  }
  auto max_iterator = max_element(cnt.begin(), cnt.end());
  return distance(cnt.begin(), max_iterator);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> v1(n / 2);
  vector<ll> v2((n + 1) / 2);
  for (ll i = 0; i < n; i++) {
    cin >> (i % 2 == 0 ? v1[i / 2] : v2[(i - 1) / 2]);
  }
  ll mode1 = getMode(v1);
  ll mode2 = getMode(v2);
  if (mode1 == mode2) {
    ll mode3 = get2ndMode(v1, mode1);
    ll mode4 = get2ndMode(v2, mode2);
    cout << min((v1.size() - count(all(v1), mode1)) + v2.size() -
                    count(all(v2), mode4),
                (v2.size() - count(all(v2), mode2)) + v1.size() -
                    count(all(v1), mode3))
         << endl;
  } else {
    cout << v1.size() - count(all(v1), mode1) + v2.size() -
                count(all(v2), mode2)
         << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  ll n,k,l;
  cin >> n >> k;
  if(n > k) {
    ll a = n%k;
    l = ((n-a)/k)*k;
  } else {
    l = k;
  }
  while(1) {
    ll n2 = n-l;
    if(n2 < 0) n2 *= -1;
    if(n2 >= n) break;
    n = n2;
  }
  if(n > k-n) n=k-n;

  cout << n << endl;
}

Measured memory_bytes: 256
use std::io::*;//Not mine.
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 a:char = read();
    if(a < 'a'){
        println!("A");
    }else{
        println!("a");
    }
}

Measured memory_bytes: 2124
n=int(input())
a=list(map(int,input().split()))
if n!=1 and len(set(a))==1:
  print(0)
  exit()
l=[0 for i in range(10**6+1)]
for i in range(n):
  l[a[i]]+=1
if n!=1 and min(a)>max(a)/2:
  ct=0
  for i in range(len(l)):
    if l[i]==1:
      ct+=1
  print(ct)
  exit()
d={}
ans=0
for i in range(n):
  x=a[i]
  if x not in d:
    if l[a[i]]==1:
      flag=1
      for j in range(1,int(x**0.5)+2):
        if x%j==0:
          if x!=j and l[j]>0:
            flag=0
            break
          if x!=x//j and x%(x//j)==0 and l[x//j]>0:
            flag=0
            break
      if flag==1:
        ans+=1
        d[x]=1
      else:
        d[x]=0
  else:
    ans+=d[x]
print(ans)

Measured memory_bytes: 167432
import sys
sys.setrecursionlimit(10**6)

n = int(input())
deg = [0 for _ in range(n)]
adj = [[] for _ in range(n)]
for _ in range(n-1):
	a, b = map(int, input().split())
	adj[a-1].append(b-1)
	adj[b-1].append(a-1)
	deg[a-1] += 1
	deg[b-1] += 1

M = max(deg)
if M == 1:
	print("Second")
elif M == 2:
	if n%2 == 1:
		print("First")
	else:
		print("Second")
else:
	for i in range(n):
		if deg[i] > 2:
			ori = i
			break

	l = [[] for _ in range(n)]
	def dfs(x, rt):
		cnt = 0
		for v in adj[x]:
			if v == rt:
				continue
			else:
				l[x].append(dfs(v, x))
				if l[x][-1] == 1:
					cnt += 1
		if not l[x]:
			return 1
		elif len(l[x]) == 1:
			return 1^l[x][0]
		elif cnt > 1:
			print("First")
			sys.exit()
		elif cnt == 1:
			return 0
		else:
			if x == ori:
				print("First")
				sys.exit()
			return 1

	dfs(ori, -1)
	print("Second")

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

using namespace std;
using ll = long long;

struct p {
  int x, y, x1, y1;
  p(int x, int y, int x1, int y1) : x(x), y(y), x1(x1), y1(y1) {}
};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> v(h, vector<int>(w));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> v[i][j];
    }
  }
  vector<p> ans;
  for (int i = 0; i < h; ++i) {
    for (int j = 1; j < w; ++j) {
      if (v[i][j - 1] % 2) {
        ans.push_back(p(i, j - 1, i, j));
        v[i][j]++;
      }
    }
  }
  for (int i = 1; i < h; ++i) {
    if (v[i - 1][w - 1] % 2) {
      ans.push_back(p(i - 1, w - 1, i, w - 1));
      v[i][w - 1]++;
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i].x + 1 << " " << ans[i].y + 1 << " " << ans[i].x1 + 1 << " "
         << ans[i].y1 + 1 << endl;
  }
}

Measured memory_bytes: 5232
import math

def calc(A, B) : 
  a = math.log(A)
  b = math.log(B)
  if a > b : 
    print('GREATER')
  elif b > a : 
    print('LESS')
  else : 
    print('EQUAL')
    
A = int(input())
B = int(input())

calc(A, B)

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////



#define MAX_V 200000//調節！！！！！！！！！！！！！！！！！！！！！！！！
struct edge{ll to,cost;};
ll d[MAX_V];//頂点sからの最短距離
ll V;//頂点数！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
vector<edge>G[MAX_V];
void dijkstra(ll s){
    priority_queue<l_l,vector<l_l>,greater<l_l>> que;//firstは最短距離、secondは頂点の番号
    fill(d,d+V+1,inf);//頂点番号は0~V-1でも1~Vでもお好きな方で
    d[s]=0;
    que.push(l_l(0,s));
    while(!que.empty()){
        //greater<l_l>なのでfirstが小さい順に取り出せる！
        l_l p=que.top();que.pop();
        ll v=p.second;
        if(d[v]<p.first)continue;
        for(ll i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(l_l(d[e.to],e.to));
            }
        }
    }
}
////////////////////////////////////////


int main(){fastio
    ll n;cin>>n;V=n;
    vector<l_l>v[n+1];
    rep(i,1,n-1){
        ll a,b,c;cin>>a>>b>>c;
        G[a].pb({b,c});
        G[b].pb({a,c});
    }
    ll q,k;cin>>q>>k;
    dijkstra(k);
    while(q--){
        ll a,b;cin>>a>>b;
        cout<<d[a]+d[b]<<endl;
    }

    
    return 0;
}


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

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
void solve()
{
    int n;
    cin >> n;
    if(n % 2 == 0){
        cout << -1 << endl;
        return;
    }
    int cnt = 1;
    int k = 7;
    while(true){
        if(k % n == 0){
            cout << cnt << endl;
            return;
        }
        if(cnt > n){
            cout << -1 << endl;
            return;
        }
        k = (k % n) * 10 + 7;
        cnt++;
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 3756
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#define endl '\n'
#define MAX_N 100005
#define pii pair<int,int>
#define ll long long
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
using namespace std;
int n, m, src;
vector<pair<int, int> >g[MAX_N];
ll dis[MAX_N];
bool vis[MAX_N];
void dfs(int u)
{
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i].first;
        if(vis[v]==0)
        {
            vis[v]=1;
            dis[v]=min(dis[v],dis[u]+g[u][i].second);
            dfs(v);
        }
    }
}
int main()
{
    //FREI;
    std::ios::sync_with_stdio(false);
    cin>>n;
    int u,v,cost;
    for(int i=0;i<n-1;i++)
    {
        cin>>u>>v>>cost;
        g[u].push_back(pii(v,cost));
        g[v].push_back(pii(u,cost));
    }
    for (int i = 0; i <= n; i++) dis[i] = 1LL<<63-1;
	memset(vis, 0, sizeof(vis));
    int q,k;
    cin>>q>>k;
    src=k;
    vis[k]=1;
    dis[k]=0;
    dfs(k);
    for(int i=0;i<q;i++)
   {
       cin>>u>>v;
       cout<<dis[u]+dis[v]<<endl;
   }
    return 0;
}


Measured memory_bytes: 12800
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

int main() {
	ll K;
	cin >> K;
	vector<ll> a(K);
	for (int i = 0;i < K;i++) {
		cin >> a[i];
	}
	ll X = 2; ll Y = 2;
	bool ok = true;
	for (int i = K - 1;i >= 0;i--) {
		Y = Y - (Y%a[i]) + a[i] - 1;
		X = X + (a[i] - X % a[i]) % a[i];
		if (X > Y) {
			ok = false;
			break;
		}
	}
	if (ok)
		cout << X << " " << Y << endl;
	else
		cout << -1 << endl;
	return 0;
}


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


typedef long long i64;
const i64 inf = (i64)1.05e18;


int main()
{
	int n, m;
	vector<pair<int, int>> events;
	vector<i64> costs;

	scanf("%d%d", &n, &m);
	costs.resize(m);
	for(int i = 0; i < m; i++) {
		int l, r, c;
		scanf("%d%d%d", &l, &r, &c);
		costs[i] = c;
		events.push_back({l - 1, (i + 1)});
		events.push_back({r - 1, -(i + 1)});
	}
	sort(events.begin(), events.end());

	vector<i64> e_dists(m, inf), v_dists(n, inf);
	set<pair<i64, i64>> usable;
	int it = 0;

	v_dists[0] = 0;

	for(int v = 0; v < n; v++) {

		if(v > 0) {
			v_dists[v] = usable.empty() ? inf : usable.begin()->first;
			//printf("v %d: %lld\n", v, v_dists[v]);
		}

		while(it < (int)events.size() && events[it].first == v) {
			int eid = abs(events[it].second) - 1;
			bool start = (events[it].second >= 0);
			it += 1;
			if(start) {
				e_dists[eid] = v_dists[v] + costs[eid];
				usable.insert({e_dists[eid], eid});
			} else {
				usable.erase({e_dists[eid], eid});
			}
		}
	}

	i64 ans = v_dists[n - 1];
	if(ans >= inf) {
		ans = -1;
	}

	printf("%lld\n", ans);

	return 0;
}

/* waffle */


Measured memory_bytes: 7152
#include <stdio.h>
int main()
{
    int i,a,b,c,flag=0;
    scanf("%d%d",&a,&b);
    for(i=1;i<=3;i++)
    {
        c = a*b*i;
        if(c%2!=0)
        {
            flag = 1;
            printf("Yes\n");
            break;
        }
    }
    if(flag==0)
        {
            printf("No\n");
        }
    return 0;
}


Measured memory_bytes: 128
use proconio::input;

struct DP {
    dp: Vec<Vec<Vec<f64>>>,
    n: usize,
}

impl DP {
    pub fn new(n: usize) -> DP {
        DP {
            dp: vec![vec![vec![-1.0; n + 1]; n + 1]; n + 1],
            n: n,
        }
    }

    fn calc(&mut self, i: usize, j: usize, k: usize) -> f64 {
        if self.dp[i][j][k] > 0.0 {
            self.dp[i][j][k]
        } else if i == 0 && j == 0 && k == 0 {
            0.0
        } else {
            let r = (self.n as f64
                + if i > 0 { self.calc(i - 1, j, k) * (i as f64) } else { 0.0 }
                + if j > 0 { self.calc(i + 1, j - 1, k) * (j as f64) } else { 0.0 }
                + if k > 0 { self.calc(i, j + 1, k - 1) * (k as f64) } else { 0.0 }
            ) / ((i + j + k) as f64);
            self.dp[i][j][k] = r;
            r
        }
    }
}

fn main() {
    input! {
        n: usize,
    }
    let mut ijk = [0; 3];
    for _ in 0..n {
        input! {
            a: usize,
        }
        ijk[a - 1] += 1;
    }

    println!("{}", DP::new(n).calc(ijk[0], ijk[1], ijk[2]));
}


Measured memory_bytes: 217968
#include <iostream>

using namespace std;

int M[]{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366};
string W[]{"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};

int main() {
    int m, d;
    while (cin >> m >> d) {
        if (m == 0) break;
        cout << W[(M[m - 1] + d - 1) % 7] << endl;
    }
}


Measured memory_bytes: 3004
#include<stdio.h>
#include<stdlib.h>
int MIN(int a,int b){return a<b?a:b;}
int ta[1010],to[2000010],nt[2000010],co[1000010],F[1010];
int MF(int s,int t,int e,int min){
  if(s==t||min==0)return min;
  int i,r;
  F[s]=1;
  for(i=ta[s];i+1;i=nt[i]){
    if(F[to[i]])continue;
    r=MF(to[i],t,e,MIN(min,co[i]));
    co[i]-=r;
    co[(i+e)%(2*e)]+=r;
    if(r)return r;
  }
  return 0;
}
//呼び出す方
//sからtへの最大流を求める　ノード数v辺の数e　aからbへキャパcのフローが流れる
int maxf(int s,int t,int v,int e,int *a,int *b,int *c){
  int i,f,r;
  for(i=0;i<v;i++)ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    co[ta[a[i]]=i  ]=c[i];
    co[ta[b[i]]=i+e]=0;
  }
  for(f=0;r=MF(s,t,e,1000000000);f+=r){
    for(i=0;i<v;i++)F[i]=0;
  }
  return f;
}
int main(){
  int n,s,t,i,j,l,u,v,f[100010]={};
  int a[200010],b[200010],c[200010],e=0,ans=0,d[100010];
  scanf("%d %d %d",&n,&s,&t);
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&v);
    d[i]=u-v;
    if(abs(d[i])<=s||t<=abs(d[i])&&abs(d[i])<=s*2){
      ans++;//printf("%d %d",u,v);
      f[i]=1;
    }
  }//printf("%d\n",ans);
  for(i=0;i<n;i++){
    if(f[i]||d[i]>0)continue;
    for(j=0;j<n;j++){
      if(f[j]||d[j]<0)continue;
      l=abs(d[i]+d[j]);
      if(l<=s||t<=l&&l<=s*2){
	a[e  ]=i;
	b[e  ]=j;
	c[e++]=1;
      }
    }
  }
  for(i=0;i<n;i++){
    if(f[i])continue;
    if(d[i]<0){
      a[e  ]=n;
      b[e  ]=i;
      c[e++]=1;
    }
    else{
      a[e  ]=i;
      b[e  ]=n+1;
      c[e++]=1;
    }
  }
  //for(i=0;i<e;i++)printf("%d %d\n",a[i],b[i]);
  printf("%d\n",maxf(n,n+1,n+2,e,a,b,c)+ans);
  return 0;
}
  
      



Measured memory_bytes: 3484
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <string>

int GCD(int a, int b){
    if(!b) return a;
    return GCD(b, a%b);
}
int LCM(int a, int b){
    return a/GCD(a, b)*b;
}

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

    std::string str;
    std::cin >> str;
    for(auto rit=str.rbegin(); rit!=str.rend(); ++rit){
        std::cout << *rit;
    }
    std::cout << "\n";
    return 0;
}

Measured memory_bytes: 2976
import java.util.Scanner;
import java.util.stream.IntStream;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] a1 = IntStream.range(0,N).map(i->scan.nextInt()).toArray();
        int[] a2 = IntStream.range(0,N).map(i->scan.nextInt()).toArray();
        int ans = 0;
        for(   int i=0;i<N;++i){
            int res=0;
            for(int j=0;j<=i;j++){
                res+=a1[j];
            }
            for(int j=i;j<N;++j){
                res+=a2[j];
            }
            ans = Math.max(res,ans);
        }
        System.out.println(ans);

    }
}

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

using namespace std;

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> ans;
  
  for(int i = 0; i < K; i++)
  {
    int AA = A + i;
    ans.push_back(AA);
    if(AA == B)break;
  }
  for(int j = 0; j < K; j++)
  {
    int BB = B - j;
    int cntBB = 0;
    for(int l = 0; l < ans.size(); l++)
    {
      if(ans[l] == BB)cntBB++;
    }
    if(cntBB == 0)ans.push_back(BB);
    if(BB == A)break;
  }
  
  sort(ans.begin(), ans.end());
  
  for(int k = 0; k < ans.size(); k++)
  {
    cout << ans[k] << endl;
  }
  
  return 0;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
   ll i,j;
   string s;
   cin>>s;
   ll n=s.size();
   s=s+'R';

   ll b,c,d;
   c=0;
   vector<ll> a(n,0);

   for(i=1;i<n+1;i++){
       if(s[i-1]=='R'&&s[i]=='L') b=i;
       if(s[i-1]=='L'&&s[i]=='R'){
           ll tw=(i-1)/2-(c-1)/2;
           if(c==0) tw=(i-1)/2+1;
           ll on=i-c-tw;
           if(b%2==0) {
               a[b]=tw;
               a[b-1]=on;
           }
           else{
               a[b-1]=tw;
               a[b]=on;
           }
           c=i;
       }
   }
   for(i=0;i<n;i++){
       if(i==0) cout<<a[0];
       else cout<<" "<<a[i];
   }
   cout<<endl;
   return 0;
}


Measured memory_bytes: 1404
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=[],o=[],u=0;u<t;u++){var i=r[u+1].split(" ").map(function(e){return Number(e)-1});o.push(i[0]),n.push(i)}for(var f=t*(t-1)/2,l=new Array(t).fill(0),a=new Array(t).fill(0),c=[],p=0;p<t;p++)c.push(p);for(var s=0,d=0;c.length>0;){var b=c.shift();if(o[o[b]]==b){d+=1;var v=o[b],y=Math.max(a[b],a[v])+1;s<y&&(s=y),a[b]=y,a[v]=y,l[b]+=1,l[v]+=1,l[b]!=t&&(o[b]=n[b][l[b]],c.push(b)),l[v]!=t&&(o[v]=n[v][l[v]],c.push(v))}}d==f?console.log(s):console.log(-1)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 51124
#include <iostream>

using namespace std;

int N;
int h[101];

int bt(int l, int r)
{
  // len == 1
  if (l == r)
    return h[l];

  // len >= 2
  for (int i = l; i <= r; i++) {
    if (h[i] == 0) {
      if (i == l)
        return bt(l + 1, r);
      if (i == r)
        return bt(l, r - 1);
      return bt(l, i - 1) + bt(i + 1, r);
    }
  }

  for (int i = l; i <= r; i++)
    h[i] -= 1;

  return bt(l, r) + 1;
}

int main()
{
  cin >> N;

  for (int i = 0; i < N; i++)
    cin >> h[i];

  cout << bt(0, N - 1) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main() {
	char s[111];
	scanf("%s", s);
	
	bool chk = true;
	for(int i=1;s[i];i++)
		if(s[i]==s[i-1]) chk = false;
	puts(!chk ? "Bad" : "Good");
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int n,m,i,j,k,ans;
int a[305][305],b[305];
bool ban[305];

int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)
        for(j=1;j<=m;++j)
        scanf("%d",&a[i][j]);
	ans=n;
	for(i=1;i<=m;++i)
	{
		for(j=1;j<=m;++j) b[j]=0;

		for(j=1;j<=n;++j)
            for(k=1;k<=m;++k)
            if(!ban[a[j][k]])
            {
                ++b[a[j][k]];
                break;
            }
		for(j=k=1;j<=m;++j)
            if(b[j]>b[k]) k=j;
		ban[k]=true;
		if(b[k]<ans) ans=b[k];
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';


int main() {
	int n, y;
	cin >> n >> y;
	for (int i = n; i >=0; i--) {
		for (int j = n-i; j >=0; j--) {
			if (9000 * i + 4000 * j == y - 1000 * n) {
				cout << i << " " << j << " " << n - i - j;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1;
	}

	

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


int main()
{
	int n;
	int p[25];
	int i;
	int ans = 0;
	scanf("%d", &n);
	for (i = 0;i < n;i++)scanf("%d", &p[i]);
	for (i = 1;i < (n - 1);i++)
	{
		if (p[i - 1] <= p[i] && p[i] <= p[i + 1])ans++;
		if (p[i - 1] >= p[i] && p[i] >= p[i + 1])ans++;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<vector<int>> plan(n,vector<int>(3));
  for (int i=0; i<n; i++){
    cin >> plan.at(i).at(0) >> plan.at(i).at(1) >> plan.at(i).at(2);
  }
  bool flag = 1;
  for (int i=0; i<n; i++){
    int dur,path;
    int t = plan.at(i).at(0);
    if (i==0){
      dur = plan.at(i).at(0);
      path = abs(plan.at(i).at(1))+abs(plan.at(i).at(2));
    }
    else{
      dur  = plan.at(i).at(0)-plan.at(i-1).at(0);
      path = abs(plan.at(i).at(1)-plan.at(i-1).at(1))+abs(plan.at(i).at(2)-plan.at(i-1).at(2));
    }
    if(t%2==0){
      if ((plan.at(i).at(1)+plan.at(i).at(2))%2==0 & dur>=path) continue;
      else{
        flag = 0;
        break;
      }
    }
    else if(t%2==1){      
      if ((plan.at(i).at(1)+plan.at(i).at(2))%2==1 & dur>=path) continue;
      else{
        flag = 0;
        break;
      }
    }
  }
  cout << (flag?"Yes":"No") << endl;
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<tuple>

using namespace std;

int main(){
  for(int n,l;cin>>n>>l,n|l;){
    vector<tuple<int,int,int> > v;
    for(int i=0;i<n;i++){
      char d;
      int p;
      cin>>d>>p;
      v.emplace_back(i+1,(d=='R')-(d=='L'),p);
    }
    int la,ra;
    int lt=-1,rt=-1;
    for(int i=0;!v.empty();i++){
      int pop[123]={};
      for(auto it=v.begin();it!=v.end();){
	if(get<2>(*it)==0){
	  la=get<0>(*it);
	  lt=i;
	  it=v.erase(it);
	}else if(get<2>(*it)==l){
	  ra=get<0>(*it);
	  rt=i;
	  it=v.erase(it);
	}else{
	  get<2>(*it)+=get<1>(*it);
	  pop[get<2>(*it)]++;
	  ++it;
	}
      }
      for(auto &e:v){
	if(pop[get<2>(e)]>1){
	  get<1>(e)*=-1;
	}
      }
    }
    cout<<max(lt,rt)<<' '<<((lt<rt)?ra:la)<<endl;
  }
}

Measured memory_bytes: 1200
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	a,b,k = readline() |> split |> parseMap
	if a+b<k
		println("0 0")
	elseif a<k
		println("0 ",a+b-k)
	else
		println(a-k," ",b)
	end
end

main()

Measured memory_bytes: 110532
#include<bits/stdc++.h>
using namespace std;
int n,sum;
bool p=0;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int a,b;
		cin>>a>>b;
		if(a==b)sum++;
		else sum=0;
		if(sum==3)p=1;
	}
	if(p)cout<<"Yes";
	else cout<<"No";
	return 0; 
}

Measured memory_bytes: 3620
A = int(input())
B = int(input())

if A == 1 and B == 2:
        print(3)
elif A == 1 and B == 3:
        print(2)
elif A == 2 and B == 1:
        print(3)
elif A == 2 and B == 3:
        print(1)
elif A == 3 and B == 1:
        print(2)
elif A == 3 and B == 2:
        print(1)

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

int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double tmp = abs(M_PI * m / (double)30 - M_PI * (h + m / (double)60) / (double)6);
    double theta = min(tmp, 2 * M_PI - tmp);
    double ans = sqrt(a*a + b*b - 2*a*b*cos(theta));
    //printf("%f\n", theta * 180 / M_PI);
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 4256
N = int(input())
A = sorted([int(input()) for _ in range(N)])

if N % 2 == 1:
    A11 = A[:N//2+1]
    A12 = A[N//2+1:]
    ans1 = sum(A12)*2-sum(A11)*2+A11[-1]+A11[-2]

    A21 = A[:N//2]
    A22 = A[N//2:]
    ans2 = sum(A22)*2-sum(A21)*2-A22[0]-A22[1]

    ans = max(ans1, ans2)
else:
    A1 = A[:N//2]
    A2 = A[N//2:]
    ans = sum(A2)*2-sum(A1)*2+A1[-1]-A2[0]


print(ans)


Measured memory_bytes: 8516
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

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

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

int main(){
	int a,b;
	cin>>a>>b;
	if(a>b)swap(a,b);
	for(int i=a;i<=b;i++){
		if(i-a == b-i){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class ABBQEasy {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    vector<int> L(2 * N);
    rep(i, 2 * N) cin >> L[i];
    sort(ALL(L));
    int ans = 0;
    while (L.size() > 1) {
      ans += L[L.size() - 2];
      L.pop_back();
      L.pop_back();
    }
    cout << ans << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  ABBQEasy solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define WA cout<<"char134217728";exit(0)
#define RE throw
#define TLE sleep(1000)
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
V<pii> v;
int n, m;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n){
    int a, b;
    cin >> a >> b;
    v.pb(mp(a, b));
  }
  sort(all(v));

  ll s = 0;
  for(pii p:v){
    if(p.se >= m){
      s += ll(p.fi) * m;
      break;
    }else{
      s += ll(p.fi) * p.se;
      m -= p.se;
    }
  }
  cout << s << endl;
}

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

struct yosinagasayuri {
	int A, B;
};

int mareitaso(const void* x, const void* y) {
	int a = ((const struct yosinagasayuri*)x)->A, b = ((const struct yosinagasayuri*)y)->A;
	return a < b ? -1 : a > b;
}

int N, M;
struct yosinagasayuri yakusimaruhiroko[114514];

int mimorinnSize = 0;
int mimorinn[114514];

void mimorinnAdjust(int pos) {
	for (;;) {
		int maxPos = pos;
		int i;
		for (i = 1; i <= 2; i++) {
			int candidatePos = pos * 2 + i;
			if (candidatePos < mimorinnSize && mimorinn[maxPos] < mimorinn[candidatePos]) {
				maxPos = candidatePos;
			}
		}
		if (maxPos == pos) {
			if (pos == 0) break;
			pos = (pos - 1) / 2;
		} else {
			int t = mimorinn[pos];
			mimorinn[pos] = mimorinn[maxPos];
			mimorinn[maxPos] = t;
			pos = maxPos;
		}
	}
}

void mimorinnPut(int value) {
	mimorinn[mimorinnSize++] = value;
	mimorinnAdjust(mimorinnSize - 1);
}

int mimorinnGet(void) {
	int ret;
	if (mimorinnSize <= 0) return 0;
	ret = mimorinn[0];
	mimorinn[0] = mimorinn[--mimorinnSize];
	if (mimorinnSize > 0) mimorinnAdjust(0);
	return ret;
}

int main(void) {
	int i;
	int haradahitomi = 0;
	int nannzyouyosino = 0;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &yakusimaruhiroko[i].A, &yakusimaruhiroko[i].B) != 2) return 1;
	}
	qsort(yakusimaruhiroko, N, sizeof(*yakusimaruhiroko), mareitaso);
	for (i = 0; i <= M; i++) {
		while (nannzyouyosino < N && yakusimaruhiroko[nannzyouyosino].A <= i) {
			mimorinnPut(yakusimaruhiroko[nannzyouyosino++].B);
		}
		haradahitomi += mimorinnGet();
	}
	printf("%d\n", haradahitomi);
	return 0;
}


Measured memory_bytes: 1788
ns=list(map(str,input().split()))
mp={}
for n in ns:
	if n in mp:
		mp[n]=mp[n]+1
	else:
		mp[n]=1
long_word=''
freq_word=''
max_len=0
max_fre=0

for k,v in mp.items():
	if max_len<len(k):
		long_word=k
		max_len=len(k)
	if max_fre<v:
		freq_word=k
		max_fre=v
print(freq_word,long_word)

Measured memory_bytes: 7356