akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    b = S()
    b = b[0]
    if b == "A":
        print("T")
    elif b == "T":
        print("A")
    elif b == "C":
        print("G")
    elif b == "G":
        print("C")
    return

#B
def B():
    s = S()
    agct = ["A", "G", "C", "T"]
    ans = 0
    for num, i in enumerate(s):
        ansb = 0
        if i in agct:
            ansb += 1
            for k in range(num+1, len(s)):
                if s[k] in agct:
                    ansb += 1
                else:
                    break
        ans = max(ans, ansb)
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 39280
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	int n;
	cin >> n;
	vector<int>a;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	sort(a.begin(), a.end());
	cout << a.back() - a.front() << endl;


	return 0;
}

Measured memory_bytes: 256
<?php

$m = array();
for($i = -5; $i < 15; $i++){
	$m[$i] = array();
	for($j = -5; $j < 15; $j++){
		$m[$i][$j] = 0;
	}
}

while($line = fgets(STDIN)){
	$arr = explode(",", trim($line));
	$x = intval($arr[0]);
	$y = intval($arr[1]);
	$s = intval($arr[2]);
	
	$m[$x][$y - 1]++;
	$m[$x - 1][$y]++;
	$m[$x][$y]++;
	$m[$x + 1][$y]++;
	$m[$x][$y + 1]++;
	if($s >= 2){
		$m[$x - 1][$y - 1]++;
		$m[$x + 1][$y - 1]++;
		$m[$x - 1][$y + 1]++;
		$m[$x + 1][$y + 1]++;
		
	}
	if($s >= 3){
		$m[$x][$y - 2]++;
		$m[$x - 2][$y]++;
		$m[$x + 2][$y]++;
		$m[$x][$y + 2]++;
	}
}

$w = 0;
$max = 0;
for($i = 0; $i < 10; $i++){
	for($j = 0; $j < 10; $j++){
		if($m[$i][$j] == 0){
			$w++;
		}
		if($max < $m[$i][$j]){
			$max = $m[$i][$j];
		}
	}
}

echo $w."\n";
echo $max."\n";

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

int main()
{
    string list[500] = {};
    int cnt[500] = {};
    int num = 0;

    int N;

    cin >> N;
    string inp;
    for (int i=1;i<=N;i++){
        cin >> inp;
        for (int j=1;j<=num;j++){
            if(list[j]==inp){
                cnt[j]++;
                break;
            }
            if(j==num){
                num++;
                list[num] = inp;
                cnt[num]++;
                break;
            }
        }
        if(num==0){
            num++;
            list[num] = inp;
            cnt[num]++;
        }
    }

    cin >> N;
    for (int i=1;i<=N;i++){
        cin >> inp;
        for (int j=1;j<=num;j++){
            if(list[j]==inp){
                cnt[j]--;
                break;
            }
            if(j==num){
                num++;
                list[num] = inp;
                cnt[num]--;
                break;
            }
        }
    }
    int max =0;

    for (int i=1;i<=num;i++){
        if(cnt[i]>max){
            max = cnt[i];
        }
    }

    cout << max << endl;
}

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

int main() {
    map<char, int> num;
    for (int i = 0; i < 3; i++) {
        char c;
        cin >> c;
        num[c]++;
    }
    if (num.size() == 3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vector<pll> P(N);
    REP(i,0,N) cin >> P[i].second >> P[i].first;

    bool f = true;
    ll sum = 0;
    ASC(P);
    REP(i,0,N) {
        sum += P[i].second;
        if(sum > P[i].first) {
            f = false;
            break;
        }
    }
    if(f) PR("Yes");
    else PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 6364
n = int(input())
l = []
o = set()
t = 0
c = 0
ans = -1
for i in range(n):
    l.append(int(input())-1)

for i in range(n):
    if l[t] == 1:
        ans = c+1
        break
    else:
        if t in o:
            break
        else:
            c += 1
            o.add(t)
            t = l[t]

print(ans)


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

long long modpow(long long a,long long n,long long MOD){
    int ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ret;
}

long long modinv(long long a, long long MOD) {
    return modpow(a, MOD - 2, MOD);
}

int main(){
    long long n,k;
    int mod = 1000000007;
    cin >> n >> k;
    long long MAX = n * 2 + 1;
    long long fact[MAX];
    //factorial mod, modulo inverse
    fact[0] = fact [1] = 1;
    for (int i = 2;i < MAX + 1;i++) {
        fact[i] = fact[i - 1] * i % mod;
    }
    long long ans = 0;
    long long cmb1,cmb2;

    for (int i = 0;i < min(n,k + 1);i++){
        cmb1 = (fact[n - 1] * modinv(fact[i],mod) % mod) * modinv(fact[n - i - 1],mod) % mod;
        cmb2 = (fact[n] * modinv(fact[i],mod) % mod) * modinv(fact[n - i],mod) % mod;
        ans += cmb1 * cmb2 % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

int fpow(int x, int y){
  int ret = 1;
  while(y > 0){
    if(y % 2 == 1) ret = mul(ret, x);
    x = mul(x, x);
    y /= 2;
  }
  return ret;
}

int invp(int x){
  return fpow(x, mod - 2);
}

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

  int n, k;
  cin >> n >> k;
  vi v(n);
  for(int& x : v)
    cin >> x;
  int res = 0;
  for(int i = 0; i < n; i++){
    int x = 0;
    for(int j = i + 1; j < n; j++){
      if(v[i] > v[j]) x++;
    }
    int before = 0;
    for(int j = 0; j < i; j++){
      if(v[j] < v[i]) before++;
    }
    int add2 = mul(mul(k, k + 1), invp(2));
    res = add(res, mul(x, add2));
    int add3 = mul(mul(k - 1, k), invp(2));
    res = add(res, mul(before, add3));
  }
  cout << res;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 100100100100
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

 
int main(){
    string s;
    cin >> s;
    
    reverse(s.begin(), s.end());
    
    vector<int> sum(s.size());
    int count = 0;
    rep(i,s.size()){
        if(s[i] =='B'){
            sum[i] = count++;
            
        }
    }
    ll ans = 0;
    rep(i,s.size()){
        if(s[i] =='B'){
            ans += i - sum[i];
        }
    }
    
    
    
    
    cout << ans << endl;
    
    
    
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int m; cin >> m;
  int a[n];
  REP(i,n) cin >> a[i];
  int total = 0;
  REP(i,n) total+=a[i];
  double v = total / (4.0*m);
  int cnt=0;
  REP(i,n) {
    if (a[i] >= v) cnt++;
  }
  if (cnt >= m) COUT("Yes");
  else COUT("No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define      fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define      debug       printf("\n<<CameHere>>\n")
#define      mem(x,y)    memset(x, y, sizeof(x))
#define      all(qz)     qz.begin(),qz.end()
#define      rall(qz)    qz.rbegin(),qz.rend()
#define      inf         1000000000000000000
#define      mod         1000000007
#define      Sqr(x)      ((x)*(x))
#define      ll          long long
#define      mk          make_pair
#define      pb          push_back
#define      pi          acos(-1.0)
#define      cos(a)      cos(a*pi/180)
#define      sin(a)      sin(a*pi/180)
#define      tan(a)      tan(a*pi/180)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
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));}
/*---------AL ASAD NUR RIYAD------------*/


int main()
{
    fastt

    string s;
    cin>>s;
    ll cnt=0;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') cnt=3;
    else if(s[0]=='R'&&s[1]=='R') cnt=2;
    else if(s[1]=='R'&&s[2]=='R') cnt=2;
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R') cnt=1;
    cout<<cnt<<endl;
    return 0;
}
























Measured memory_bytes: 3636
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 2019;

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

  int64_t N;
  cin >> N;
  vector<int> prime_idx;
  int64_t i = 2;
  if (N < 4 && N > 1) {
    prime_idx.push_back(1);
  } else {
    while (i * i <= N) {
      if (N % i == 0) {
        N /= i;
        int cnt = 1;
        while (N % i == 0) {
          cnt++;
          N /= i;
        }
        prime_idx.push_back(cnt);
      }
      i++;
    }
    if (N != 1)
      prime_idx.push_back(1);
  }
  int res = 0;
  for (auto idx : prime_idx) {
    idx -= 1;
    res++;
    int i = 2;
    while (idx > 0) {
      idx -= i;
      i++;
      if (idx >= 0) {
        res++;
      }
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;
typedef  struct {
    int human;
    int step;

   
}height;
int Sum(height h) {
    return h.human + h.step;
}

int main(){
    int N;
    cin  >> N;
	
    vector<height> A(N);
    for(int i = 0 ; i < N ; i++){
        cin >> A[i].human;
		
    }
	// for(int i = 0 ; i < N ; i++){
	// 	printf("A[%d] = %d\n",i,A[i].human);
	// }
	

    long long int sum=0;
	int tmp =0;
    for(int i = 0 ; i < N-1 ; i++){
		// printf("step %d sum%lld\n",tmp,sum);
		
		if(A[i+1].human >= Sum(A[i])){
			continue;
		}
		tmp = Sum(A[i]) - A[i+1].human;
		
		A[i+1].step = tmp;
		sum += tmp;
		// printf("step %d sum%lld\n",tmp,sum);
    }
	cout << sum << endl;
}


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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	int s, w;
	cin >> s >> w;
	cout << (w >= s ? "unsafe" : "safe") << endl;
	return 0;
}



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

string s;
int p;

ll A[200][300];
int idx;

ll bnf();

ll get_num(){

  if(s[p]=='('){
    
    p++;

    ll res=bnf();
    
    p++;

    return res;
  }
  
  if('a'<=s[p]&&s[p]<='z') return A[idx][s[p++]];
  
  ll num=0;
  
  while('0'<=s[p]&&s[p]<='9') num=num*10+s[p]-'0', p++;

  return num;
  
}

ll bnf3(){

  ll res=get_num();
  
  while(p<s.size()){

    if(s[p]=='^'){

      p++;

      ll r=get_num();

      ll tmp=1;

      for(int i=0;i<r;i++) tmp*=res;

      res=tmp;
      
    }else break;
    
  }
  
  return res;
}

ll bnf2(){

  ll res=bnf3();

  while(p<s.size()){

    if(s[p]=='*'){

      p++;

      ll r=bnf3();
      
      res*=r;
      
    }else break;
    
  }
  
  return res;
}

ll bnf(){

  ll res=bnf2();
  
  while(p<s.size()){
    
    if(s[p]=='+'){

      p++;
      
      ll r=bnf2();
      
      res+=r;
      
    }
    else if(s[p]=='-'){

      p++;

      ll r=bnf2();

      res-=r;
      
    }else break;
    
  }
  
  return res;
}

void change(){
  
  for(int i=0;i<s.size();i++)
    if((s[i]==')'||('a'<=s[i]&&s[i]<='z')||('0'<=s[i]&&s[i]<='9')))
      if((s[i+1]=='('||('a'<=s[i+1]&&s[i+1]<='z')||('0'<=s[i+1]&&s[i+1]<='9')))
	if(!('0'<=s[i]&&s[i]<='9'&&'0'<=s[i+1]&&s[i+1]<='9'))
	  s=s.substr(0,i+1)+'*'+s.substr(i+1);

  
  for(int i=0;i<s.size();i++)
    
    if(s[i]==' ')
      
      while(s[i]==' '&&i+1<s.size()&&s[i+1]==' ') s.erase(s.begin()+i);
  

  if(s[0]==' ') s.erase(s.begin());
  
  if(s[s.size()-1]==' ') s.erase(s.begin()+s.size()-1);

  for(int i=0;i<s.size();i++)
    if(s[i]==' ')
      if((s[i-1]==')'||('a'<=s[i-1]&&s[i-1]<='z')||('0'<=s[i-1]&&s[i-1]<='9')))
	if((s[i+1]=='('||('a'<=s[i+1]&&s[i+1]<='z')||('0'<=s[i+1]&&s[i+1]<='9'))) s[i]='*';

  for(int i=0;i<s.size();i++)
    
    if(s[i]==' ') s.erase(s.begin()+i), i--;
  
  
}

int main(){
  
  for(int T=0;T<200;T++)
    
    for(int i=0;i<300;i++) A[T][i]=rand();
  
  while(1){

    string tmp=s;
    
    getline(cin,s);
    
    if(s==".") break;
    
    change();
    
    ll base[200];

    for(int T=0;T<200;T++){
      idx=T;
      p=0;
      base[T]=bnf();
    }
    
    while(1){
      
      getline(cin,s);
      
      if(s=="."){
	cout<<"."<<endl;
	break;
      }
      
      change();
      
      bool ans=true;
      
      for(int T=0;T<200;T++){
          
	idx=T;  
	p=0;
      
	ll r=bnf();
	
	if(base[T]!=r) ans=false;
	
      }
      
      if(ans) cout<<"yes"<<endl;
      else cout<<"no"<<endl;
      
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 3596
# coding: utf-8
# Your code here!
N=int(input())
K=int(input())

n=(str(N))
dp=[[0]*(K+1) for i in range(len(n))]
dp[0][0]=1
dp[0][1]=int(n[0])


count=1
for i in range(len(n)-1):
    dp[i+1][0]+=dp[i][0]
    dp[i+1][1]+=(dp[i][0])*9
    #print(count)
    for j in range(1,K):
        dp[i+1][j]+=dp[i][j]
        dp[i+1][j+1]+=max((dp[i][j]-1)*9+int(n[i+1]),0) if j==count else dp[i][j]*9
    if int(n[i+1])!=0:
        count+=1
    dp[i+1][K]+=dp[i][K]
    
print(dp[-1][-1])


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<functional>
using namespace std;

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

int main(void) {
	vector<int>b;
	vector<int>a;
	vector<bool>used;
	bool v = true;
	int n;
	int k = 1;
	int x, y, z;
	scanf("%d", &n);
	f(i, n)k = k * 2;
	f(i, k) {
		scanf("%d", &x);
		a.push_back(x);
		used.push_back(false);
	}
	sort(a.begin(), a.end(), greater<int>());
	b.push_back(a[0]);
	used[0] = true;
	y = 1;
	f(i, n) {
		z = 0;
		f(j, k) {
			if ((!used[j]) && (a[j] < b[z])) {
				used[j] = true;
				b.push_back(a[j]);
				z++;
				if (z >= y)break;
			}
		}
		if (z < y) {
			v = false;
			break;
		}
		y = y * 2;
		sort(b.begin(), b.end(), greater<int>());
	}
	if (v)printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 2804
#include<iostream>
#include<string>
using namespace std;
int main()
{
	while (1)
	{
		string a;
		cin >> a;
		if (a == "0"){ return 0; }
		int c = 0;
		for (int b = 0; b < a.size(); b++){ c += a[b] - '0'; }
		cout << c << endl;
	}
}

Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <memory>

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

using namespace std;

struct N;

typedef shared_ptr<N> PN;

struct N{
	PN a, b;
};

PN make_tree(const string& s){
	int t = 0;
	for(int i = s.size() - 2; i >= 1; --i){
		if(t == 0 && s[i] == ','){
			PN p(new N);
			p->a = make_tree(string(s.begin() + 1, s.begin() + i));
			p->b = make_tree(string(s.begin() + i + 1, s.end() - 1));
			return p;
		}
		else if(s[i] == ')'){
			++t;
		}
		else if(s[i] == '('){
			--t;
		}
	}
	return nullptr;
}

string stringify(PN p){
	return p ? string("(") + stringify(p->a) + "," + stringify(p->b) + ")" : string();
}

PN intersect(PN& p, PN& q){
	if(!p || !q){
		return nullptr;
	}
	PN r(new N);
	r->a = intersect(p->a, q->a);
	r->b = intersect(p->b, q->b);
	return r;
}

PN unite(PN& p, PN& q){
	if(!p && !q){
		return nullptr;
	}
	else if(!p){
		return PN(new N(*q));
	}
	else if(!q){
		return PN(new N(*p));
	}
	PN r(new N);
	r->a = unite(p->a, q->a);
	r->b = unite(p->b, q->b);
	return r;
}

int main(){
	string a, s, t;
	while(cin >> a >> s >> t){
		PN p = make_tree(s);
		PN q = make_tree(t);
		if(a == "i"){
			cout << stringify(intersect(p, q)) << endl;
		}
		else{
			cout << stringify(unite(p, q)) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, size_t second_itr) {
	std::string tmp;
	for (size_t i = first_itr; i < second_itr + 1; i++) {
		tmp.push_back(str.at(i));
	}
	return tmp;
}
ll max(ll a, ll b) {
	return a > b ? a : b;
}
ll min(ll a, ll b) {
	return a < b ? a : b;
}


int main() {
	int a; cin >> a;
	cout << 3 * a * a << endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s[3];
  char t[3];
  int i,cnt=0;
  scanf("%s",s);
  scanf("%s",t);
  if(s[0]==t[0]){
    cnt++;
  }
  if(s[1]==t[1]){
    cnt++;
  }
  if(s[2]==t[2]){
    cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 128
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }

use std::cmp::max;
fn main() {
    input! {
        w: i64,
        h: i64,
        n: i64,
        xya: [(i64, i64, i8); n],
    }
    let mut p = (0,0,w,h);
    for (x,y,a) in xya {
        match a {
            1 => if p.0 < x { p.0 = x },
            2 => if p.2 > x { p.2 = x },
            3 => if p.1 < y { p.1 = y },
            4 => if p.3 > y { p.3 = y },
            _ => panic!()
        };
    }
    println!("{}", max(p.2-p.0,0) * max(p.3-p.1, 0));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define MOD 1000000007
int main()
{
   ll r,d,x;
   cin>>r>>d>>x;
   for(int i=1;i<=10;i++)
   {
       x=x*r-d;
       cout<<x<<endl;
   }
   
    return 0;

    
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let n = read!(usize);
    let p = read![[usize]];

    let mut count = 0;
    for y in 1..n - 1 {
        let x = y - 1;
        let z = y + 1;

        if (p[x] < p[y] && p[y] < p[z]) || (p[x] > p[y] && p[y] > p[z]) {
            count += 1;
        }
    }

    println!("{}", count)
}


Measured memory_bytes: 4352
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();
        long M = scan.nextLong();
        long ans = 0;
        if(N>=3 && M>=3){
            ans = (N-2)*(M-2);
        }else if(N==1 || M==1){
            if(N==1 && M==1)ans=1;
            else if(N==1)ans = M-2;
            else if(M==1)ans = N-2;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=100000 +117;
const int MM= +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int a[NN]={};
int b[NN]={};
vector<int> p[NN];
bool has[NN]={};
int fa[NN]={};
int ord[NN]={};
LL dp[NN]={};
LL sumb[NN]={};
int getfa(int x){
	return x==fa[x]?x:fa[x]=getfa(fa[x]);
}
bool cmp(int x,int y){
	return a[x]<a[y];
}
int main(){
	//open();
	n=read();
	m=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
		b[i]=read();
		a[i]=max(a[i]-b[i],0);
		fa[i]=i;
		ord[i]=i;
	}
	for(int i=1;i<=m;++i){
		int x=read(),y=read();
		p[x].push_back(y);
		p[y].push_back(x);
	}
	sort(ord+1,ord+1+n,cmp);
	for(int i=1;i<=n;++i){
		int x=ord[i];
		has[x]=1;
		dp[x]=a[x];
		sumb[x]=b[x];
		for(int j=0;j<p[x].size();++j){
			int cur=p[x][j];
			if(has[cur]){
				int rt=getfa(cur);
				if(rt==x)continue;
				sumb[x]+=sumb[rt];
				dp[x]=min(dp[x],max(dp[rt],a[x]-sumb[rt]));
				fa[rt]=x;
			}
		}

	}
	printf("%lld\n",dp[getfa(1)]+sumb[getfa(1)]);
	close();
	return 0;
}

Measured memory_bytes: 9084
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> A(N), s(N+1, 0), x(N+1, 0);
    Rep (i, N) {
        cin >> A[i];
        s[i+1] = s[i] + A[i];
        x[i+1] = x[i] ^ A[i];
    }
    s.push_back(s[N]+1);
    x.push_back(x[N]);

    ll ans = 0;
    Rep (left, N) {
        ll ok = left, ng = N+1;
        while (ng - ok > 1) {
            ll mid = (ok + ng) / 2;
            if (s[mid] - s[left] == (x[mid] ^ x[left])) ok = mid;
            else ng = mid;
        }
        // cout << left << "\t" << ok << endl;
        ans += ok - left;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8036
{
  const main = (input: string) => {
    const r = reader(input)
    const N = r.n()
    const l = r.ns()
    let res = 0

    l.sort((a, b) => b - a)
    for (let i = 0; i < N - 2; i++) {
      const l1 = l[i]

      for (let j = i + 1; j < N - 1; j++) {
        const l2 = l[j]
        const k = j + 1

        const p = _bound(k, N, i => l[i] > l1 - l2)

        res += p - j - 1
      }
    }

    console.log(res)
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const _bound = (lo: number, hi: number, compare: (v: number) => boolean) => {
    while (lo < hi) {
      const mid = lo + Math.floor((hi - lo) / 2)

      if (compare(mid)) {
        lo = mid + 1
      } else {
        hi = mid
      }
    }
    return hi
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}


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

static const int N = 100;

int main(){
  int n,p[N+1],m[N+1][N+1];
  cin>>n;

  for(int i = 1;i<=n;i++){
    cin>>p[i-1]>>p[i];
  }

  for(int i = 1; i<=n;i++) m[i][i] = 0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j = i+l-1;
      m[i][j] = (1<<21);
      for(int k = i; k <=j-1;k++){
	m[i][j] = min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout << m[1][n]<<endl;
  return 0;
}




Measured memory_bytes: 3120
def ExtGCD(a, b):
    if b == 0:
        return a, 1, 0
    else:
        d, x, y = ExtGCD(b, a % b)
        x -= (a // b) * y
        return d, y, x
def ModInv(a, mod):
    return ExtGCD(a, mod)[1] % mod
def ModComb(n, k, mod):
    if n < k or n < 0 or k < 0:
        return 0
    elif n == 0 or k == 0:
        return 1
    q, a = 1, 1
    for i in range(n-k+1, n+1):
        q = (q * i) % mod
    for i in range(2, k+1):
        a = (a * i) % mod
    return int(q * ModInv(a, mod) % mod)
def main():
    n,k=map(int,input().split())
    mod=10**9+7
    for i in range(1,k+1):
        print(ModComb(n-k+1,i,mod)*ModComb(k-1,i-1,mod)%mod)
        # 最後のに%modつけるの忘れてた。。。。。。
main()

Measured memory_bytes: 3316
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a,b,c) for(b=(c);b<(a);b++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll combination(ll, ll);
int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	char ans = '1';
	for (int i = 0; i < k; i++) {
		if (s[i] != '1') {
			ans = s[i];
			break;
		}
		if (i >= s.size()) {
			break;
		}
	}
	cout << ans;
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let f: Vec<_> = (0..n).map(|_| {
        let mut bp = 0;
        for _ in 0..10 {
            let f: usize = sc.cin();
            bp = (bp << 1) | f;
        }
        bp
    }).collect();
    let p: Vec<Vec<i64>> = (0..n).map(|_| (0..11).map(|_| sc.cin()).collect()).collect();
    let mut ans: i64 = -100000000000000;
    for bp in 1..1024 {
        ans = max!(ans,
        (0..n).map(|k| {
            let i = (f[k] & bp).count_ones();
            p[k][i as usize]
        }).sum());
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int x,a;
    cin>>x>>a;

    if(x < a) {
        cout<<0<<endl;
    } else {
        cout<<10<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 3e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 9;
const ll inf = 1e18;

int n, m;
string str1, str2;
int dp[M][M];

int solve(int i, int j) {
  if(i == n || j == m)
    return 0;
  int& ret = dp[i][j];
  if(~ret)
    return ret;
  ret = 0;
  if(str1[i] == str2[j])
    return ret = solve(i + 1, j + 1) + 1;
  ret = max(ret, max(solve(i+1, j), solve(i, j + 1)));
  return ret;
}

void print(int i, int j) {
  if(i == n || j == m)
    return;
  int ans = solve(i, j);
  int c2 = solve(i+1, j), c3 = solve(i, j + 1);
  if(str1[i] == str2[j]) {
    cout << str1[i];
    print(i + 1, j + 1);
  } else if(ans == c2)
    print(i+1, j);
  else if(ans == c3)
    print(i, j + 1);
  else
    assert(0);
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif

  cin >> str1 >> str2;
  n = str1.size(), m = str2.size();
  memset(dp, -1, sizeof dp);
  cerr << solve(0, 0);
  print(0, 0);
  return 0;
}


Measured memory_bytes: 36224
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(v) for (auto itr = v.begin(), itr != v.end(); ++itr)
#define LB(v, x) lower_bound(v.begin(), v.end(), x) - v.begin()
#define UB(v, x) upper_bound(v.begin(), v.end(), x) - v.begin()
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int R;
    cin >> R;
    cout << fixed << setprecision(10) << 2 * R * 3.1415926535 << endl;

    return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a == c) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
 
int n, m, s, d[105][105], t1[1005], t2[1005], t3[1005], v[105][105];
int main()
{
	int i, j, k;
	cin >> n >> m;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			d[i][j] = 1e9;
		}
		d[i][i] = 0;
	}
	for (i = 0; i < m; i++) {
		scanf ("%d %d %d", &t1[i], &t2[i], &t3[i]);
		d[t1[i]][t2[i]] = d[t2[i]][t1[i]] = t3[i];
//		v[t1[i]][t2[i]] = v[t2[i]][t1[i]] = 1;
	}
	for (k = 1; k <= n; k++) {
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= n; j++) {
				if (i == j) continue;
	//			for (k = 1; k <= n; k++) {
					if (d[i][k] + d[k][j] < d[i][j] && i != k && k != j) {
						d[i][j] = d[i][k] + d[k][j];
							v[i][j] = v[j][i] = 1;
					}
	//			}
			}
		}
	}
	for (i = 0; i < m; i++) s += v[t1[i]][t2[i]];
	cout << s;
    return 0;
}

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

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

  uint32_t ans = k;
  n--;
  k--;
  for (int i = 0; i < n; i++) {
    ans *= k;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    bool flg = true;
    for(int i=0;i<N;i+=2) if(S[i] == 'L') flg = false;
    for(int i=1;i<N;i+=2) if(S[i] == 'R') flg = false;
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
from heapq import heappop,heappush
N,M = map(int,input().split())
T = [[] for i in range(N)]
for i in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    T[a].append(b)
    T[b].append(a)

INF = float("inf")
D = [INF]*N
A = [0]*N
Q = [[0,0,-1]]
while Q:
    d,v,p = heappop(Q)
    if d >= D[v]:continue
    A[v] = p
    D[v] = d
    d += 1
    for c in T[v]:
        if c == p:continue
        if d >= D[c]:continue
        heappush(Q,[d,c,v])
if INF in D:
    print("No")
else:
    print("Yes")
    for i in range(1,N):
        print(A[i]+1)

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

vector<vector<int>> edges;

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int n;
    cin >> n;
    edges.resize(n);
    FOR(i, n){
        string s;
        cin >> s;
        FOR(j, n){
            if (s[j]=='1'){
                edges[i].push_back(j);
                edges[j].push_back(i);
            }
        }
    }

    int sol = -1;
    FOR(u, n) {
        vector<int> d(n);
        queue<int> Q;
        Q.push(u);
        d[u] = 1;
        bool good = 1;
        int md = 0;
        while(!Q.empty() && good){
            int q = Q.front(); Q.pop();
            md = max(md, d[q]);
            for(auto v : edges[q]){
                if (d[v] && (abs(d[v]-d[q])!=1)){
                    good = 0;
                    break;
                }
                if (!d[v]){
                    d[v] = d[q]+1;
                    Q.push(v);
                }
            }
        }
        if (good){
            sol = max(sol, md);
        }
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

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

int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(),a.end());
  int od=0;
  if((a[1]-a[0])%2==1)od=2;
  cout << a[2]-a[1]+(a[1]-a[0])/2+od;
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int natsuyasumi = sc.nextInt();
		int kazu = sc.nextInt();
		int shukudaiyaruhi = 0;

//	宿題の数分、宿題やる日を宿題番号分だけ増やす
		for(int i=0 ; i<kazu ; i++) {
			int bangou = sc.nextInt();
			shukudaiyaruhi += bangou;
		}

//	遊べる日数が0日以上かどうか判断
		if(natsuyasumi-shukudaiyaruhi>=0) {
			System.out.print(natsuyasumi-shukudaiyaruhi);
		}
		else {
			System.out.print(-1);
		}
	}
}

Measured memory_bytes: 37852
#include <stdio.h>
#include <stdlib.h>
#define N 100000
 
typedef struct{
  int p,l,r,o
    }Node;
 
Node T[N];
 
int main(void){
  int i,j,id,c[N],a,b,d;
   
  scanf("%d",&a);   
  for(i = 0 ; i < a ; i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  for(i = 0 ; i < a ; i++){
    scanf("%d",&id);
    scanf("%d",&c[i]);
    T[id].o = c[i];    
    if(T[id].o != 0){
      for(j = 0 ; j < T[id].o ; j++){
    scanf("%d",&b);
    if(j == 0){
      T[id].l = b;
      d = b;
      T[b].p = id;
    }
    else {
      T[d].r = b;
      d = b;
      T[b].p = id;
    }   
      }
    }
  }
  
  for(i = 0 ; i < a ; i++){
    printf("node %d: parent = %d, ",i,T[i].p);
    id = i; 
    T[i].o = T[id].o;
    for(j = 0 ; T[id].p != -1 ; j++){
      id = T[id].p;
    }
 
    printf("depth = %d, ",j);
     
    if(T[i].p == -1){
      printf("root, ");
    }
    else if((T[i].p != -1) && (T[i].l != -1)){
      printf("internal node, ");
    }
    else if(T[i].l == -1){
      printf("leaf, ");
    }
      
    if(T[i].o != 0){
      if(T[i].o == 1){
    printf("[%d]\n",T[i].l);
      }
      else {
    printf("[%d, ",T[i].l);
    for(d = T[i].l ; T[d].r != -1 ;){
      printf("%d",T[d].r);
      d = T[d].r;
      if(T[d].r != -1) printf(", ");
    }
    printf("]\n");
      }
    }
    else {
      printf("[]\n");
    } 
  }
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(int i=a; i<n; i++)
#define loop(i,a,n)	for(int i=a; i>=n; i--)

int main() 
{		
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long long int a;
	cin>>a;
	long long int b[a],ct=0;
	map<long long int,long long int> m;
	map<long long int,long long int> v;
	forr(i,0,a)
		cin>>b[i], m[b[i]]++;
	for(auto const t: m)
	{
		ct+=((t.second*(t.second-1))/2);
		long long int x=((t.second*(t.second-1))/2);
		long long int y=(((t.second-1)*(t.second-2))/2);
		v[t.first]=(x-y);
	}
	forr(i,0,a)
		cout<<(ct-v[b[i]])<<'\n';
	return 0;	
}

Measured memory_bytes: 18944
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    routes = list(map(string_to_int, inputs))
    current = [0, 0]
    t = 0
    for r in routes:
        diff_t = r[0] - t
        diff = abs(r[1] - current[0]) + abs(r[2] - current[1])

        if diff_t >= diff and (diff_t % 2) == (diff % 2):
            current = [r[1], r[2]]
            t = r[0]
        else:
            return 'No'
    return 'Yes'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)


Measured memory_bytes: 35300
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int N,A,B;
  cin>>N>>A>>B;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int ans=0;
  for(int i=1;i<N;i++)ans+=min((v[i]-v[i-1])*A,B);
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {

    vl x(4);
    rep(i, 4) {
        cin >> x[i];
    }
    sort(all(x));

    ll y[4] = {1, 4, 7, 9};
    rep(i, 4) {
        if(x[i] != y[i]) {
            out("NO");
            re0;
        }
    }

    out("YES");
    re0;
}

Measured memory_bytes: 256