akhauriyash/Code-Regression huggingface dataset:
import numpy as np

# get N
N = int(input())

countup = np.zeros(100, dtype=int)

for x in range(1,N+1):
    sx = str(x)
    A = int(sx[0])
    B = int(sx[-1])
    countup[A*10+B] += 1

ans = 0
for x in range(1,N+1):
    sx = str(x)
    A = int(sx[0])
    B = int(sx[-1])
    ans += countup[B*10+A]

print(ans)


Measured memory_bytes: 12504
#include<bits/stdc++.h>
using namespace std;
long long n,a[200001],f[200001],g[200001],d;
long long ans;
int main()
{
	scanf("%lld%lld",&n,&d);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		ans+=a[i];
	}
	f[1]=a[1];
	for(int i=2;i<=n;i++)f[i]=min(f[i-1]+d,a[i]);
	g[n]=a[n];
	for(int i=n-1;i>=1;i--)g[i]=min(g[i+1]+d,a[i]);
	for(int i=2;i<=n-1;i++)ans+=min(f[i],g[i]);
	printf("%lld",ans+(n-1)*d);
}

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


int main(){
	int a[25],n;
	while(cin>>n&&n){
		int k=0,m=32;
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		while(m){
			m-=(m%5-1+5)%5;
			cout<<m<<endl;
			m-=min(m,a[k]);
			cout<<m<<endl;
			k=(k+1)%n;
		}
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

string query(ll n){
  string res;
  printf("? %lld\n",n);
  fflush(stdout);
  cin>>res;
  return res;
}

void answer(ll n){
  printf("! %lld\n", n);
  fflush(stdout);
}

int main(){
	cin.sync_with_stdio(false);
  ll dig=1;
  bool f=true;
  for(ll i=10;i<=1000000000;i*=10){
    if(query(i)=="N"){
      f=false;
      break;
    }
    dig++;
  }
  if(f){
    for(ll i=9;i<=9999999999;i=i*10+9){
      if(query(i)=="Y"){
        answer((i+1)/10);
        return 0;
      }
    }
  }
  string res;
  rep(i,dig){
    if(i==dig-1){
      repl(j,i==0?1:0,10){
        string tmp=res+(char)('0'+j)+"0";
        if(query(stoll(tmp))=="Y"){
          answer(stoll(res+(char)('0'+j)));
          return 0;
        }
      }
    }else{
      ll lb=i==0?1:0,ub=10;
      while(ub-lb>1){
        ll mid=(ub+lb)/2;
        string tmp=res+(char)('0'+mid);
        if(query(stoll(tmp))=="Y")lb=mid;
        else ub=mid;
      }
      res+=(char)('0'+lb);
    }
  }
	return 0;
}


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

int main()
{
    int w , n , a , b;
    char ch;
    int ans[31] ;
    cin >> w;
    cin >> n;
    for(int i=1 ; i<=w ; i++){
        ans[i]=i;
    }
    for(int i=1 ; i<=n ; i++){
        cin >> a >> ch >> b;
        swap(ans[a] , ans[b]);
    }
    for(int i=1 ; i<=w ; i++){
    cout << ans[i] <<endl;
    }
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.io.*;
public class Main {
	private static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	private static int getInt(){return Integer.parseInt(parseStdin());}
    private static String parseStdin(){
        String strNum=null;
        try {
            String line=br.readLine();
            if(line!=null)
                if(!line.isEmpty())
                    strNum = line;
        }
        catch(IOException e){}
        return strNum;
    }
	public static void main(String args[]){
		int n=getInt();
		while(n!=0){
			int sum=getInt();
			int ans=sum;
			for(int i=1;i<n;i++){
				int x=getInt();
				if(sum>0)sum+=x;
				else	sum=x;
				if(ans<sum)
					ans=sum;
			}
			n=getInt();
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 24652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
bool inline isPalindromicNew(int n)
{
    string s = to_string(n);
    if (s[0] == s[4] and s[1] == s[3])
    {
        return true;
    }

    return false;
}
bool inline isPalindromic(int n)
{
    vi digits(5);
    rep(i, 0, 5)
    {
        digits[i] = n % 10;
        n /= 10;
    }
    if (digits[0] == digits[4] and digits[1] == digits[3])
    {
        return true;
    }
    return false;
}
int main()
{
    //freopen("B.01.in","r",stdin);
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    vi digits(5);
    int a, b, all = 0;
    // cin >> a >> b;
    scanf("%d %d", &a, &b);
    rep(i, a, b + 1)
    {
        if (isPalindromicNew(i))
        {
            all++;
        }
    }
    // cout << all << endl;
    printf("%d\n", all);
    return 0;
}

Measured memory_bytes: 3648
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

def div_min(h,w)
    ret=INF
    1.upto(h-1) do|i|
        if i*w>(h-i)*(w/2)
            val=(i*w-(h-i)*(w/2)).abs
        else
            val=(i*w-(h-i)*(w/2+w%2)).abs
        end
        ret=val if ret>val
    end
    return ret
end
H,W=get_i
if (H%3).zero? or (W%3).zero?
    puts 0
    exit
end
res=min(div_min(H,W),div_min(W,H))
puts min(min(H,W),res)

Measured memory_bytes: 14376
#include<bits/stdc++.h>
  using namespace std;
    #define ll long long
    #define ull unsigned long long
    #define fr(i,a,b) for(int i =a ; i < b; i++)
    #define FR(i,a,b) for(int i =a ; i > b; i--) 
    #define frj(j,a,b) for(int j =a ; j < b; j++)
    #define FRE(i,a,b) for(int i =a ; i >= b; i--) 
    #define fre(i,a,b) for(int i =a ; i <= b; i++)
    #define fra(s) for(auto it = s.begin(); it != s.end() ; ++it)

    #define mkp make_pair 
    #define pb push_back
    #define pii pair<int,int>
    #define speed   ios::sync_with_stdio(false), cin.tie(0) , cout.tie(0)
    //#define c(a,b) cout<<a<<"--"<<b<<endl;
    #define frv(i,a,v) for(int i =  a ; i < v.size() ; ++i)
    #define cp(a,i)  cout<<a[i].first<<" "<<a[i].second<<endl;
    #define pp(a) cout<<a.first<<" "<<a.second<<endl;
    //sum array
    #define sa(n) int a[n]; int s[n];cin>>a[0];s[0]=a[0];fr(i,1,n) {cin>>a[i];s[i]=s[i-1]+a[i];}
    #define sa1(n) int a[n+1]; long long s[n+1]; a[0]=0; s[0]=0;cin>>a[1];s[1]=a[1];fr(i,2,n+1) {cin>>a[i];\
    s[i]=s[i-1]+a[i];}

    #define pr(a,n) fr(i,0,n){cout<<a[i]<<" ";}cout<<endl;
    #define prv(v)   for(auto it = v.begin() ; it!= v.end() ;++it){cout<<*it<<" ";}cout<<endl;
    #define prs(s)   for(auto x : s){cout<<x<<" ";}cout<<endl;
    
    #define all(x)           x.begin(), x.end()
    #define prm(m,r,c) fr(i,0,r){frj(j,0,c){cout<<m[i][j]<<" "; }cout<<endl;}
    #define fillm(m,r,c,k) fr(i,0,r)frj(j,0,c)m[i][j]=k;
    constexpr auto PI  = 3.14159265358979323846L;
    constexpr auto eps = 1e-6;
    constexpr auto mod = 1000000007;
    #define MOD 1000000007
    #define maxv 100005
    #define MAXN 100001

  template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
  template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

  double dp[2][3000];

int main(){
      
      speed;
      int n;
      cin>>n;
        std::cout << std::fixed;
  std::cout << std::setprecision(12);

      double a[n];
      fr(i,0,n)
      cin>>a[i];
//      pr(a,n);

           dp[0][0]=1-a[0];
      dp[0][1]=a[0];
   //   prm(dp,2,5);
      fr(i,1,n)
      {

          frj(j,0,3000)
          {
            if(j>0)
            dp[1][j]=dp[0][j]*(1-a[i]) + dp[0][j-1]*a[i];
            else
            dp[1][j]=dp[0][j]*(1-a[i]);

          }

          frj(j,0,3000)
            dp[0][j]=dp[1][j];
      }

      double an=0;
      fr(i,n/2+1,n+1)
      {
        an+=dp[0][i];
       } 


      cout<<an<<endl;
      return 0;


  }



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i,N)cin >> S[i];
    sort(S.begin(),S.end());
    S.erase(unique(S.begin(), S.end()), S.end());
    cout << S.size() << endl;

    return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX_N = 100000;

int n, a[MAX_N];
int q, k;

int main(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> k;
		cout << lower_bound(a, a + n, k) - a << ' ' << upper_bound(a, a + n, k) - a << endl;
	}
	return 0;
}



Measured memory_bytes: 3504
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


def partition(A, p, r):
    x = A[r]
    i = p - 1
    assert p <= r
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return dict(array=A, cursor=i + 1)


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    assert len(array) == array_length
    raw_result = partition(A=array, p=0, r=array_length - 1)
    array_result = raw_result['array']
    cursor = raw_result['cursor']
    array_result[cursor] = '[' + str(array_result[cursor]) + ']'
    print(*array_result)

Measured memory_bytes: 18200
import scala.annotation.tailrec

object Main extends App {

  import scala.io.StdIn._
  f

  def f: Unit = {
    val n = readLine.trim.toInt
    if (n == 0) return
    val num = toCh(List.tabulate(n){ _ ⇒ readLine.trim.toInt})
    println(n - search(num))
    f
  }
  def search(list: List[Ch]): Int = {
    def sub(prev: List[Ch], current: Ch, post: List[Ch], max: Int = 0): Int = {
      prev match {
        case c::t ⇒ sub(t, c, current::post, List(max, changeFirst(prev, current, post), changeLast(prev, current, post)).max)
        case _ ⇒ List(max, changeFirst(prev, current, post), changeLast(prev, current, post)).max
      }
    }
    list match {
      case Nil ⇒ 0
      case h::t ⇒ sub(t, h, Nil)
    }
  }
  def changeFirst(prev: List[Ch], current: Ch, post: List[Ch]): Int = {
    (prev, current, post) match {
      case (Ch(a, n)::t, Ch(_, 1), Ch(b, m)::u) if a == b && n + m >= 3 ⇒ n + m + 1 + remove(t, u)
      case (Ch(_, n)::t, Ch(a, m), _) if n >= 3 ⇒ if (m == 1) n + 1 + remove(t, post) else n + 1 + remove(t, Ch(a, m - 1)::post)
      case _ ⇒ 0
    }
  }
  def changeLast(prev: List[Ch], current: Ch, post: List[Ch]): Int = {
    (prev, current, post) match {
      case (Ch(a, n)::t, Ch(_, 1), Ch(b, m)::u) if a == b && n + m >= 3 ⇒ n + m + 1 + remove(t, u)
      case (_, Ch(a, n), Ch(_, m)::t) if m >= 3 ⇒ if (n == 1) m + 1 + remove(prev, t) else m + 1 + remove(Ch(a, n - 1)::prev, t)
      case _ ⇒ 0
    }
  }
  def remove(prev: List[Ch], post: List[Ch]): Int = {
    (prev, post) match {
      case (Ch(a, n)::t, Ch(b, m)::u) if a == b && n + m >= 4 ⇒ n + m + remove(t, u)
      case _ ⇒ 0
    }
  }
  @tailrec
  def toCh(list:List[Int], res: List[Ch] = Nil): List[Ch] = {
    list match {
      case Nil ⇒ res
      case h::t ⇒ res match {
        case Nil ⇒ toCh(t, Ch(h, 1)::res)
        case Ch(c, n)::rt if c == h ⇒ toCh(t, Ch(c, n + 1)::rt)
        case _ ⇒ toCh(t, Ch(h, 1)::res)
      }
    }
  }
  case class Ch(color: Int, num: Int)
}



Measured memory_bytes: 51724
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main()
{
	string yn[2] = { "YES","NO" };
	int a, b,c,ans=0;
	cin >> a >> b >> c;
	if (b - a != c - b) ans = 1;
	cout << yn[ans] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define setNil(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define setNegINF(x) memset((x),192,sizeof(x)) //NegINF=-INF-1
#define setNeg1(x) memset((x),255,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int n,m,ls,lt;
string s,t;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m>>s>>t;
	ls=s.size();
	lt=t.size();
	int g=__gcd(ls,lt);
	for(int i=0,j=0;i<ls;i+=ls/g,j+=lt/g){
		if(s[i]!=t[j]){
			cout<<"-1\n";
			return 0;
		}
	}
	cout<<1ll*ls*lt/g<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long long LL;

const int N = 1e5 + 5;
int a[105], b[105];

int main() {
#ifdef ANONYM
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif

  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  for (int i = 1; i <= n - 1; i++) cin >> b[i];
  int sum = b[1] + b[n - 1];
  for (int i = n - 1; i >= 2; i--) {
    sum += min(b[i], b[i - 1]);
  }
  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

#define ll long long

int main() {
	int a = 0, b = 0, j, c[6], hoge, ans;
	cin >> a >> b;
	ans = 0;
	for (int i = a; i <= b; i++) {
		hoge = i;
		j = 0;
		while (hoge > 0) {
			c[j] = hoge % 10;
			hoge = hoge / 10;
			j++;
		}
		if (c[0] == c[4] && c[1] == c[3])ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  string s;cin>>s;

  if(s=="Sunny")out("Cloudy");
  else if(s=="Cloudy")out("Rainy");
  else if(s=="Rainy")out("Sunny");

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char str1[8][9];
	char str2[8][9];
	int i, j, k;
	int n;
	
	for (i = 0; i < 8; i++){
			scanf("%s", str1[i]);
	}
	
	for (n = 1; n <= 3; n++){
		
		printf("%d\n", n * 90);
		
		for (i = 0; i < 8; i++){
			for (j = 0, k = 7; j < 8; j++, k--){
				str2[i][j] = str1[k][i];
			}
			str2[i][8] = '\0';
		}
		
		for (i = 0; i < 8; i++){
			for (j = 0; j < 9; j++){
				str1[i][j] = str2[i][j];
			}
		}
		
		for (i = 0; i < 8; i++){
			printf("%s\n", str1[i]);
		}
	}
	return (0);
}

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

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

    sort(A.begin(), A.end());

    vector<vector<ll>> v(2);
    rep(i, N / 2) {
        v[0].push_back(A[i]);
        v[1].push_back(A[N - 1 - i]);
    }

    ll ans = v[1][0] - v[0][0];
    rep(i, N / 2 - 1) {
        ans += abs(v[0][i] - v[1][i + 1]) + abs(v[1][i] - v[0][i + 1]);
    }
    if (N != 1 && N % 2 == 1) {
        ans += max(A[N / 2] - v[0][N / 2 - 1], v[1][N / 2 - 1] - A[N / 2]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 5092
#include<stdio.h>

int main()
{
    double a,b,c,d,e,f,x,y;

    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF)
    {
        y=(a*f-c*d)/(a*e-b*d);
        x=(c-b*y)/a;
        printf("%.3f %.3f\n",x,y);
    }
    return 0;
}



Measured memory_bytes: 2040
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }

// 整数の桁数を返す ( log(N) )
template <class Integer> Integer GetDigit(Integer n) {
    if (n == 0) return 1;
    Integer d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

// 素数かどうかを返す ( O(sqrt(N)) )
template <class Integer>
constexpr bool IsPrime(const Integer n) noexcept {
    if (n < 4) return n == 2 || n == 3;
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
    for (Integer i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}


int main()
{
    int K; cin >> K;
    int A, B; cin >> A >> B;

    range_for (i, A, B)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

    return 0;
}



Measured memory_bytes: 3636
x,n=map(int,input().split())
if n==0:
    print(x)
# elif x==1 and n==1:
#     lst=list(map(int,input().split()))[:n]
#     print(lst[0]-1)
# elif 
else:
    lst=list(map(int,input().split()))[:n]
    for j in range(1,100000):
        x1=abs(abs(x)+abs(j))
        x2=abs(abs(x)-abs(j))
        if x not in lst:
            print(x)
            break
        if x2 not in lst:
            print(x2)
            break
        elif x1 not in lst:
            print(x1)
            break
        else:
            continue
        
        
        
    

Measured memory_bytes: 9200
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
// const ll MOD = 998244353;
const double PI=3.14159265358979323846;



int main() {
    ll n; cin >> n;
    ll x, m; cin >> x >> m;
    vector<ll> A(100010), sum(100010);
    A[0] = x;
    sum[0] = x;
    map<ll, int> ch;
    ch[x] = 0;
    int i = 1;
    while(1) {
        A[i] = (A[i-1] * A[i-1]) % m;
        sum[i] = sum[i-1] + A[i];
        if(ch.find(A[i]) != ch.end()) break;
        ch[A[i]] = i;
        i++;
    }
    int s = ch[A[i]]; int t = i;
    int c = t - s;
    ll res = 0;
    n -= s;
    res += (n/c) * (sum[t] - sum[s]);
    if(s+(n%c)-1 >= 0) res += sum[s+(n%c)-1];
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 8016
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	string s;
	int value = 700;
	cin >> s;
	if (s[0] == 'o') value += 100;
	if (s[1] == 'o') value += 100;
	if (s[2] == 'o') value += 100;
	cout << value << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A ,B;
    do{
        cin>>A;
    }while(A<0||A>100);
    do
    {
        cin>>B;
        if(B%2 !=0)
            return 0;
    }while(B<2||B>1000);
    if(A >=13)
        cout<<B;
    if(A>=6&&A<=12)
        cout<<B/2;
    if(A<=5&&A>=0)
        cout<<0;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define zzz ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
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);}
int main()
{
    zzz;
    int n;
    cin>>n; int ans = 0;
    for(int i=1;i<=n;++i)
    {
        string s = to_string(i);
        ans+=s.size()%2!=0;
    }
    cout<<ans;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long a = scan.nextInt();
		long b = scan.nextInt();
		
		if (a % 2 != b % 2) {
			System.out.println("IMPOSSIBLE");
		} else {
			System.out.println((a + b) / 2);
		}
	}
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  bool c = true;
  for(int i = 0; i < m; i++) cin >> a.at(i);
  for (int A : a) {
    n -= A;
    if(n < 0) {
      c = false;
      break;
    }
  }
  if(c) cout << n << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <queue>
#include <assert.h>

using namespace std;

typedef long long ll;
const int N = (int)2e5 + 50;

int n;
int par[N];
int f[N], z1[N], z0[N];

struct node {
    int z0, z1, i;
    const bool operator < (const node &o) const{
        return 1LL * z1 * o.z0 > 1LL * z0 * o.z1;
    }
};

int find(int v) {return f[v] == v ? v : f[v] = find(f[v]);}
void unite(int u, int v) {
    u = find(u), v = find(v);
    f[u] = v;
    z1[v] += z1[u];
    z0[v] += z0[u];
}

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

    ll res = 0;
    cin >> n;
    for(int i = 1; i < n; i++) {
        cin >> par[i]; par[i]--;
    }
    for(int i = 0; i < n; i++) {
        int v; cin >> v;
        z0[i] = (v == 0);
        z1[i] = (v == 1);
        f[i] = i;
    }
    priority_queue<node> pque;
    for(int i = 1; i < n; i++) {
        pque.push({z0[i], z1[i], i});
    }
    while(!pque.empty()) {
        node nd = pque.top(); pque.pop();
        if(z1[find(nd.i)] != nd.z1 || z0[find(nd.i)] != nd.z0) continue;
        int p = find(par[find(nd.i)]);
        res += 1LL * nd.z0 * z1[p];
//            cout << nd.i << " " << nd.sum << endl;
//            assert(nd.sum == ssum[find(nd.i)]);
        unite(nd.i, p);
        if(p != 0) pque.push({z0[p], z1[p], p});
    }
    cout << res << "\n";

}

Measured memory_bytes: 7924
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
//#include <bits/stdc++.h>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// print(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 20 == 19) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<typename T> T lmaximum(const std::vector< T >& v) {return *std::max_element(v.begin(), v.end());}
template<typename T> void lunique(std::vector< T >& v) {v.erase(std::unique(v.begin(), v.end()), v.end());}
template<typename T> void lsort(std::vector< T >& v) {std::sort(v.begin(), v.end());}
template<typename T> void lgreatersort(std::vector< T >& v) {std::sort(v.begin(), v.end(), std::greater<>());}
template<typename T> bool lnext_permutation(std::vector< T >& v) {return std::next_permutation(v.begin(), v.end());}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N;
  std::cin >> N;
  std::vector< ll > va(3*N, 0LL);
  for (ll i = 0; i < 3*N; i++) {
    std::cin >> va[i];
  }

  std::sort(va.begin(), va.end());
  ll ans = 0;
  for (ll i = N; i < 3*N; i+=2) {
    ans += va[i];
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstring>

using namespace std;

int p[10];

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

    int a,b,c;
    cin >> a >> b >> c;
    p[a]++,p[b]++,p[c]++;
    bool flag = false;
    for(int i=1;i<10;i++){
        if(p[i]==2){
            cout << "Yes\n";
            flag = true;
        }
    }
    if(!flag)cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> roadstart(M);
  vector<int> roadend(M);
  for(int i = 0;i < M;i++) cin >> roadstart.at(i) >> roadend.at(i);
  vector<int> city(N,0);
  for(int i = 0;i < N;i++){
    for(int j = 0;j < M;j++){
      if(roadstart.at(j) == i+1 || roadend.at(j) == i+1) city.at(i)++;
    }
    cout << city.at(i) << endl;
  }
}

  
    
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
#define mk make_pair
using namespace std;
const int N=55;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
pair<int,int>a[N];
bool vis[N];

signed main()
{
	int n=read(),ans=n;
	for (int i=1;i<=n;i++)
	{
		a[i].x=read();
		a[i].y=read();
	}
	sort(a+1,a+1+n);
	for (int i=1;i<n;i++)
	for (int j=i+1;j<=n;j++)
	if (i!=j)
	{
		int p=a[j].x-a[i].x,q=a[j].y-a[i].y,cnt=0;
		for (int i=1;i<=n;i++) vis[i]=0;
		for (int i=1;i<=n;i++)
		if (!vis[i])
		{
			vis[i]=1;
			cnt++;
			int now=i;
			while (1)
			{
				int nxt=lower_bound(a+now+1,a+n+1,mk(a[now].x+p,a[now].y+q))-a;
				if (a[nxt]==mk(a[now].x+p,a[now].y+q))
				{
					now=nxt;
					vis[nxt]=1;
				}
				else break;
			}
		}
		ans=min(ans,cnt);
	}
	print(ans);

	return 0;
}

Measured memory_bytes: 3604
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m, q = I[:3]
l, r = I[3:3+m*2].reshape(-1, 2).T
p, q = I[3+m*2:].reshape(-1, 2).T

def main():
    res = np.zeros((n+2, n+2), dtype=np.int64)

    np.add.at(res, (1, r), 1)
    res[1, n+1] += -1 * m
    np.add.at(res, (l+1, r), -1)
    np.add.at(res, (l+1, n+1), 1)
    res = np.cumsum(res, axis=1)
    res = np.cumsum(res, axis=0)

    ans = res[p, q]
    return ans

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 66932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			int n = Integer.parseInt(sc.nextLine());/* 入力単語数 */
			if(n == 0) break;
			
			String[] words = new String[n];
			for(int i = 0 ; i < n; i++) {
				words[i] = sc.nextLine();
			}

			int n1, n2, n3, n4, n5;
			for(int i = 0; i < n; i++) {
				n1 = n2 = n3 = n4 = n5 = 0;
				for(int j = i; j < n; j++) {
					if(n1 < 5) {
						n1 += words[j].length();
						if(n1 > 5) break;
					}else if(n2 < 7) {
						n2 += words[j].length();
						if(n2 > 7) break;
					}else if(n3 < 5) {
						n3 += words[j].length();
						if(n3 > 5) break;
					}else if(n4 < 7) {
						n4 += words[j].length();
						if(n4 > 7) break;
					}else if(n5 < 7) {
						n5 += words[j].length();
						if(n5 > 7) break;
					}
				}
				if(n5 == 7) {
					System.out.println(i+1);
					break;
				}
			}
		}
	}

}



Measured memory_bytes: 33800
#include<bits/stdc++.h>
#define int long long
using namespace std;
int t,a,b,c,d,n;
map<pair<int,int>,int>dp;
int dfs(pair<int,int>x)
{
	if(x.first<0)
		return 9e18;
	if(x.first==0)
		return 0;
	if(dp.find(x)!=dp.end())
		return dp[x];
	dp[x]=9e18;
	if(9e18/d>=x.first)
		dp[x]=d*x.first;
	if(x.first%2==0)
		dp[x]=min(dp[x],dfs(make_pair(x.first/2,1))+a);
	if(x.first%3==0)
		dp[x]=min(dp[x],dfs(make_pair(x.first/3,1))+b);
	if(x.first%5==0)
		dp[x]=min(dp[x],dfs(make_pair(x.first/5,1))+c);
	if(x.second)
	{
		dp[x]=min(dp[x],dfs(make_pair(x.first-1,0))+d);
		dp[x]=min(dp[x],dfs(make_pair(x.first-2,0))+d*2);
		dp[x]=min(dp[x],dfs(make_pair(x.first+1,0))+d);
		dp[x]=min(dp[x],dfs(make_pair(x.first+2,0))+d*2);
	}
	//cout<<x.first<<' '<<dp[x]<<endl;
	return dp[x];
}
signed main()
{
	ios::sync_with_stdio(false);
	cin>>t;
	while(t--)
	{
		dp.clear();
		cin>>n>>a>>b>>c>>d;
		cout<<dfs(make_pair(n,1))<<endl;
	}
	return 0;
}

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

int main(){
    int n,A[100];
    cin >> n;
    for ( int i =0;i<n;i++)
    cin >> A[i];
    
    for(int i=n-1;i>=0;i--){
        if(i !=n-1)cout<<" ";
        cout << A[i];
    }
    cout << endl;
    
    
    return 0;
}



Measured memory_bytes: 3068
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N-1];
		int sum=0;

		for(int i=0; i<N-1; i++){
			B[i] = sc.nextInt();
		}
		A[0] = B[0];
		sum += A[0];
		for(int i=1; i<N-1; i++){
			A[i] = Math.min(B[i-1],B[i]);
			sum += A[i];
		}
		A[N-1] = Math.max(A[N-2], B[N-2]);
		sum += A[N-1];

        System.out.println(sum);
		//System.out.println(Arrays.toString(A));
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a = 0;
	int b = 0;
	int c = 0;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a < b && b < c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

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

int main(){
  string s[110];
  int n, l;
  cin >> n >> l;
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  sort(s, s+n);
  for(int i = 0; i < n; i++){
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int h,w;
char s[505][505],r[505][505];
void prt(bool f) {
    for (int i=0;i<h;++i) {
        for (int j=0;j<w;++j)
            putchar(s[i][j]=='#'?'#':f?r[i][j]:r[i][j]=='#'?'.':'#');
        putchar('\n');
    }
}
int main()
{
    scanf("%d%d",&h,&w);
    for (int i=0;i<h;++i)
        scanf("%s",s[i]);
    for (int i=0;i<h;++i) {
        r[i][0]='#';
        r[i][w-1]='.';
    }
    for (int i=0;i<h;++i)
        for (int j=1;j<w-1;++j)
            r[i][j]=i&1?'#':'.';
    prt(false);
    putchar('\n');
    prt(true);
    return 0;
}


Measured memory_bytes: 1152
/*
 * @Author: Kaizyn
 * @Date: 2020-06-21 22:13:33
 * @LastEditTime: 2020-06-21 23:31:23
 */ 
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const int N = 2e6+7;

template <int _MOD> struct Mint {
  int v = 0;
  Mint() {}
  Mint(int _v) : v((_v%_MOD+_MOD)%_MOD) {}
  Mint(long long _v) : v(static_cast<int>((_v%_MOD+_MOD)%_MOD)) {}
  Mint operator = (const int &_v) { return *this = Mint(_v); }
  Mint operator = (const long long &_v) { return *this = Mint(_v); }
  bool operator ! () const { return !this->v; }
  bool operator < (const Mint &b) const { return v < b.v; }
  bool operator > (const Mint &b) const { return v > b.v; }
  bool operator == (const Mint &b) const { return v == b.v; }
  bool operator != (const Mint &b) const { return v != b.v; }
  bool operator <= (const Mint &b) const { return v < b.v || v == b.v; }
  bool operator >= (const Mint &b) const { return v > b.v || v == b.v; }
  Mint operator + (const Mint &b) const { return Mint(v+b.v); }
  Mint operator - (const Mint &b) const { return Mint(v-b.v); }
  Mint operator * (const Mint &b) const { return Mint(1ll*v*b.v); }
  Mint operator / (const Mint &b) const { return Mint(b.inv()*v); }
  Mint& operator += (const Mint &b) { return *this = *this+b; }
  Mint& operator -= (const Mint &b) { return *this = *this-b; }
  Mint& operator *= (const Mint &b) { return *this = *this*b; }
  Mint& operator /= (const Mint &b) { return *this = *this/b; }
  Mint operator - () const { return Mint(-v); }
  Mint& operator ++ () { return *this += 1; }
  Mint& operator -- () { return *this -= 1; }
  Mint operator ++ (int) { Mint tmp = *this; *this += 1; return tmp; }
  Mint operator -- (int) { Mint tmp = *this; *this -= 1; return tmp; }
  Mint pow(int p) const {
    Mint res(1), x(*this);
    while (p) {
      if (p&1) res = res*x;
      x *= x;
      p >>= 1;
    }
    return res;
  }
  Mint inv() const { return pow(_MOD-2); }
  friend istream& operator >> (istream &is, Mint &mt) { return is >> mt.v; }
  friend ostream& operator << (ostream &os, const Mint &mt) { return os << mt.v; }
};
using mint = Mint<MOD>;

int n, k;
string s;
mint pw25[N], pw26[N], fac[N];

mint C(const int &p, const int &q) {
  return fac[p]/(fac[q]*fac[p-q]);
}

inline void solve() {
  cin >> k >> s;
  n = s.size();
  pw25[0] = pw26[0] = fac[0] = 1;
  for (int i = 1; i <= n+k; ++i) {
    pw25[i] = pw25[i-1]*25;
    pw26[i] = pw26[i-1]*26;
    fac[i] = fac[i-1]*i;
  }
  mint res = 0;
  for (int i = n; i <= n+k; ++i) {
    res += C(i-1, n-1)*pw25[i-n]*pw26[n+k-i];
    // res += C(k+n, i)*pw25[k+n-i];
  }
  cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int T = 1;
  // cin >> T;
  for (int t = 1; t <= T; ++t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 27704
height,width = map(int, input().split())
map_list = []
flag = False
for i in range(height):
    map_list.append(list(input()))
    map_list[i].append('0')
map_list.append(['0'] * width)
#print(map_list)

for h in range(height):
    for w in range(width):
        if map_list[h][w] == '#':
            #print("a")
            if '#' in [map_list[h-1][w], map_list[h+1][w], map_list[h][w-1], map_list[h][w+1]]:
                flag = True
                #print("b")
                if flag == True:
                    flag = False
                    #print("c")
            else:
                print("No")
                exit()

print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _itr ::iterator
#define forn(i, x, y) for (ll i = x; i < y; ++i)
#define ford(i, x, y) for (ll i = x; i > y; --i)
#define forne(i, x, y) for (ll i = x; i <= y; ++i)
#define forde(i, x, y) for (ll i = x; i >= y; --i)
#define rd(x) cin >> x; cin.ignore();
#define rdstr(x) getline(cin, x);
#define rdarr(x, y) for (ll i = 0; i < y; ++i) cin >> x[i];
#define rdmtr(x, y, z) for (ll i = 0; i < y; ++i) for (ll j = 0; j < z; ++j) cin >> x[i][j];
#define pb push_back

#define X first
#define Y second

#define MaxN 107
#define MaxM 507
#define Mdl 1000000007

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef ll arr[MaxN];

ll REPIT = 1;

const bool MQ = false;
ll n;
arr so;

void Solve()
{
    ll res = 0;
    cin >> n; rdarr(so, n);
    for (ll i = 0; i < n; ++i)
    {
        for (ll j = i + 1; j < n; ++j)
        {
            for (ll k = j + 1; k < n; ++k)
            {
                if (so[i] + so[j] > so[k] && so[i] + so[k] > so[j] && so[j] + so[k] > so[i] && so[i] != so[j] && so[j] != so[k] && so[i] != so[k])
                {
                    ++res;
                }
            }
        }
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef OFFLINE
    freopen("INPUT.inp", "r", stdin);
    #endif
    if (MQ == true)
    {
        rd(REPIT);
    }
    while (REPIT--) Solve();
    cout.flush();
    #ifdef OFFLINE
    fclose(stdin);
    #endif
}


Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys


def solve(X: int):
    ct = 0
    yo = 100
    while yo < X:
        yo *= 1.01
        yo = int(yo)
        ct += 1
    print(ct)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Measured memory_bytes: 63484
// Aizu Vol-10 1062: It's our delight!!
// 2017.8.18 bal4u@uu

#include <stdio.h>

int cnt[3], ok[3];
char *a[3] = { "lunch", "dinner", "midnight" };
// ???11:00-14:59, ???18:00-20:59, ??±???21:00-01:59
int tt[3][2] = { { 660, 899 } , { 1080, 1259 }, { 1260, 1559 } };

int main()
{
	int n, hh, mm, MM;
	int i, j, t;

	while (scanf("%d", &n) && n) {
		for (j = 0; j < 3; j++) cnt[j] = ok[j] = 0;
		for (i = 0; i < n; i++) {
			scanf("%d%*c%d%d", &hh, &mm, &MM);
			if (hh <= 2) hh += 24;
			if (MM >= mm) MM += hh * 60;
			else          MM += (hh + 1) * 60;
			t = hh * 60 + mm;
			for (j = 0; j < 3; j++) {
				if (tt[j][0] <= t && t <= tt[j][1]) {
					cnt[j]++;
					if (MM - t <= 8) ok[j]++;
				}
			}
		}
		for (j = 0; j < 3; j++) {
			printf("%s ", a[j]);
			if (cnt[j] == 0) puts("no guest");
			else printf("%d\n", ok[j] * 100 / cnt[j]);
		}
	}
	return 0;
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve(){
    int n;
    cin>>n;
    if(n>=30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return;
}

int main()
{
    boost();
    
    int tc=1;
    //cin>>tc;
    while(tc--)
        solve();
    return 0;
}

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), a.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int N, flag;
    flag = 0;
    int a[3][3];
    int b;
    int c[3][3];
    m0(c);

    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }

    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> b;
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(b == a[j][k]) {
                    c[j][k] = 1;
                }
            }
        }
    }

    for(int i = 0; i < 3; i++) {
        if(c[i][0] == 1 && c[i][1] == 1 && c[i][2] == 1) {
            flag = 1;
        }
    }

    for(int i = 0; i < 3; i++) {
        if(c[0][i] == 1 && c[1][i] == 1 && c[2][i] == 1) {
            flag = 1;
        }
    }

    if(c[0][0] == 1 && c[1][1] == 1 && c[2][2] == 1) {
        flag = 1;
    }

    if(c[0][2] == 1 && c[1][1] == 1 && c[2][0] == 1) {
        flag = 1;
    }

    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//by xxj
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define lowbit(x) x&-x
using namespace std;
const int inf=1e9+7;
const double eps=1e-10;
const ll linf=1e18+7;
const ll hh=523;
//const int mod=;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a,b,c;
	cin>>a>>b>>c;
	if (a+b>=c-1){
		cout<<b+c<<endl;
	}
	else{
		cout<<a+b*2+1<<endl;
	}
	return 0;
}
/*
input:
*/



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

using namespace std;

int main(){
    long long a, b, x;
    cin >> x;
    for(int i = -1000; i <= 1000; i++){
        for(int j = -1000; j <= 1000; j++){
            a = i * i;
            a *= a;
            a *= i;
            b = j * j;
            b *= b;
            b *= j;
            if(a - b == x){
                cout << i << " " << j;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
using namespace std;
int x[100000], y[100000];

int main() {
    int n, m;
    cin >> n >> m;
    for(int i=0; i<m; i++) cin >> x[i];
    sort(x, x+m);
    for(int i=0; i<m-1; i++) y[i] = x[i+1] - x[i];
    sort(y, y+m-1);
    
    int ans=0;
    for(int i=0; i<m-n; i++) ans += y[i];
    cout << ans << endl;

    return 0;
}



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

const int INF = 1e+9;

int main(){

    int H, W;
    string s[50];

    cin >> H >> W;
    for( int i = 0; i < H; i++ ) cin >> s[i];

    int white = 0; // 最初にwhiteな面の数
    int dx[] = { 0, 1, 0, -1 };
    int dy[] = { 1, 0, -1, 0 };
    int d[50][50];

    for( int i = 0; i < H; i++ ){
        for( int j = 0; j < W; j++ ){
            d[i][j] = INF;
            if( s[i][j] == '.' ) white++;
        }
    }
    d[0][0] = 1;

    queue< pair<int, int> > q;
    q.push( make_pair(0,0) );

    while( ! q.empty() ){ //queueに何か存在する間は実行
        pair<int, int> p = q.front();
        q.pop();

        for( int i = 0; i < 4; i++ ){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if( 0 <= nx && nx < W && 0 <= ny && ny < H ){
                if( s[ny][nx] == '.' && d[ny][nx] > d[p.second][p.first]+1 ){
                    d[ny][nx] = d[p.second][p.first] + 1;
                    q.push( make_pair(nx,ny) );
                }
            }
        }
    }
    
    if( d[H-1][W-1] == INF ) cout << -1 << endl;
    else cout << white - d[H-1][W-1] << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int n;
int k[maxn+5],l[maxn+5],r[maxn+5];

ll solve(vector<pii> A)
{
    ll res=0;
    sort(A.begin(),A.end());
    int ptr=A.size()-1;
    priority_queue<int> q;
    per(i,1,n)
    {
        while(ptr>=0 && A[ptr].FI==i) q.push(A[ptr--].SE);
        if(q.size())
        {
            res+=q.top();
            q.pop();
        }
    }
    return res;
}

int main()
{
    int CAS; scanf("%d",&CAS);
    while(CAS--)
    {
        scanf("%d",&n);
        rep(i,1,n) scanf("%d%d%d",&k[i],&l[i],&r[i]);
        ll ans=0;
        rep(i,1,n) if(l[i]>=r[i]) ans+=r[i]; else ans+=l[i];
        vector<pii> A,B;
        rep(i,1,n) if(l[i]>=r[i]) A.pb({k[i],l[i]-r[i]}); else B.pb({n-k[i],r[i]-l[i]});
        ans+=solve(A);
        ans+=solve(B);
        printf("%lld\n",ans);
    }
    
    return 0;
}

Measured memory_bytes: 8232
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(n-1):
  if a[i] + 1 == a[i+1]:
    ans = ans + c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef pair<int, int> P;

class UnionFind {
  public:
    vector<int> Parent;

    UnionFind(int N) {
      Parent = vector<int>(N, -1);
    }

    int root(int A) {
      if(Parent[A] < 0) return A;
      return Parent[A] = root(Parent[A]);
    }

    int size(int A) {
      return -Parent[root(A)];
    }

    bool connect(int A, int B) {
      A = root(A);
      B = root(B);
      if(A==B) {
        return false;
      }

      if(size(A) < size(B)) swap(A, B);
      Parent[A] += Parent[B];
      Parent[B] = A;
      return true;
    }
};

int main() {
  int N, K, L; cin >> N >> K >> L;
  UnionFind Uni(N);
  UnionFind U(N);
  map<P, int> m;
  for(int i = 0; i < K; ++i) {
    int p, q; cin >> p >> q;
    p--, q--;
    Uni.connect(p, q);
  }
  for(int i = 0; i < L; ++i) {
    int r, s; cin >> r >> s;
    r--, s--;
    U.connect(r, s);
  }
  for(int i = 0; i < N; ++i) {
    try {
      int cnt = m.at({Uni.root(i), U.root(i)});
      m.erase({Uni.root(i), U.root(i)});
      m.insert({{Uni.root(i), U.root(i)}, cnt+1});
    } catch(std::out_of_range&) {
      m.insert({{Uni.root(i), U.root(i)}, 1});
    }
  }
  for(int i = 0; i < N; ++i) {
    try {
      cout << m.at({Uni.root(i), U.root(i)});
    } catch(std::out_of_range&) {
      cout << 0;
    }
    if(i != N-1) cout << " ";
  }
  cout << endl;
  return 0;
}


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

int main(){
   string s;
   cin >> s;
   bool t=true;
   for(int i=0;i<3;i++){
       if(s[i]==s[i+1])t=false;
   } 
   if(t){
       cout << "Good" << endl;
   }
   else{
       cout << "Bad" << endl;
   }
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200010

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N;
int main(){
	cin>>N;
	int nowt=0,nowx=0,nowy=0,t,x,y;
	bool ans=true;
	for(int i=0;i<N;i++){
		cin>>t>>x>>y;
		t=t-nowt;
		int s=abs(x-nowx)+abs(y-nowy);
		if(s>t||((t-s)%2!=0))ans=false;
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    while(cin>>a>>b>>c>>d)
    {
        while(1)
        {
            c-=b;
            if(c<=0)
            {
                cout<<"Yes"<<endl;
                break;
            }
            a-=d;
            if(a<=0)
            { 
                cout<<"No"<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 3608