akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int arr[n];
map<int , int> add , diff;
for(int i = 0 ; i  < n ; i++){
 cin>>arr[i];
 diff[i-arr[i]]++;
 add[i+arr[i]]++;
}
int ans = 0;
for(int i = 0 ; i < n ; i++){
  ans += diff[i+arr[i]];
}
cout<<ans<<endl;
}


Measured memory_bytes: 39392
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    string o, e;
    cin >> o >> e;

    int len = o.length() + e.length();
    for(int i = 0; i < len; i++){
        if((i+1) % 2 != 0){
            cout << o[i/2];
        }
        else{
            cout << e[i/2];
        }
    }

    return 0;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0]){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
//Created by: Aditya Singh
//Bleed Blue
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define unm unordered_map<int,int>
#define pb emplace_back
#define nt _int128
#define PI 3.1415926535897932384626433
#define inf 1e18

const int N = 100005;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t;cin>>t;while(t--)
    {
        int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
        string a, b, c;
        cin >> a >> b, n = a.size(), m = b.size();
        int dp[n + 1][m + 1];
        for (i = 0; i <= n; i++)
        {
            for (j = 0; j <= m; j++)
            {
                if (i == 0 || j == 0)
                {
                    dp[i][j] = 0;
                    continue;
                }
                if (a[i - 1] == b[j - 1])
                    dp[i][j] = 1 + dp[i - 1][j - 1];
                else
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
        // cout << dp[n][m] << endl;
        for (i = n, j = m; i > 0 && j > 0;)
        {
            if (a[i - 1] == b[j - 1])
            {
                c += a[i - 1];
                i--; j--;
            }
            else if (dp[i - 1][j] > dp[i][j - 1])
                i--;
            else
                j--;
        }
        for (i = dp[n][m] - 1; i >= 0; i--)
            cout << c[i];
    }
    return 0;
}

Measured memory_bytes: 73816
#include <cstdio>
#include <iostream>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	int x=0,y=0;
	for(int i=1,a;i<=n;++i){
		scanf("%d",&a);
		if(a&1)++x;
		if(a%4==0)++y;
	}
	if(x>y+1 || (x==y+1 && x+y<n))printf("No");
	else printf("Yes");
}

Measured memory_bytes: 256
#include <iostream>
#define MAX_N 1001
using namespace std;
int n,I[MAX_N],U[MAX_N],A[MAX_N],P[MAX_N];

void b_sort(int a,int b){
  swap(I[a],I[b]);
  swap(U[a],U[b]);
  swap(A[a],A[b]);
  swap(P[a],P[b]);
}

int main(){

  while(cin >> n,n){
    for(int i = 0 ; i < n ; i++  ){
      cin >> I[i] >> U[i] >> A[i] >> P[i]; 
    }

    for(int i = 0 ; i < n-1 ; i++ )
      for(int j = n-1 ; j > 0 ; j-- )
	if(I[j-1] > I[j])b_sort(j-1,j);

    for(int i = 0 ; i < n-1 ; i++ )
      for(int j = n-1 ; j > 0 ; j-- )
	if(P[j-1] > P[j])b_sort(j-1,j);

    for(int i = 0 ; i < n-1 ; i++ )
      for(int j = n-1 ; j > 0 ; j-- )
	if(A[j-1] < A[j])b_sort(j-1,j);
    
    int teamLimit[MAX_N],now = 0;
    fill(teamLimit,teamLimit + MAX_N,0);

    for(int i = 0 ; i < n ; i++ ){
      if(now < 10){
	if(teamLimit[U[i]] < 3 ){
	  teamLimit[U[i]]++;
	  cout << I[i] << endl;
	  now++; 
	}
      } else if(now < 20){
	if(teamLimit[U[i]] < 2 ){
	  teamLimit[U[i]]++;
	  cout << I[i] << endl;
	  now++; 
	} 
      } else if(now < 26){
	  if(teamLimit[U[i]] == 0){
	    teamLimit[U[i]]++;
	    cout << I[i] << endl;
	    now++;
	  }
      } 
      if(26 == now )break;
    }
  }
  return 0;
}

Measured memory_bytes: 1176
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    H, W, K = map(int, input().split())
    S = [input() for _ in range(H)]

    ans = [[None] * W for _ in range(H)]

    cnt = 1
    for h in range(H):
        for w in range(W):
            if S[h][w] == "#":
                ans[h][w] = cnt
                cnt += 1

    # 上から下
    for h in range(1, H):
        for w in range(W):
            if ans[h][w] is None:
                if ans[h - 1][w] is not None:
                    ans[h][w] = ans[h - 1][w]

    # 下から上
    for h in range(H - 1)[::-1]:
        for w in range(W):
            if ans[h][w] is None:
                if ans[h + 1][w] is not None:
                    ans[h][w] = ans[h + 1][w]

    # 左から右
    for h in range(H):
        for w in range(1, W):
            if ans[h][w] is None:
                if ans[h][w - 1] is not None:
                    ans[h][w] = ans[h][w - 1]

    # 右から左
    for h in range(H):
        for w in range(W - 1)[::-1]:
            if ans[h][w] is None:
                if ans[h][w + 1] is not None:
                    ans[h][w] = ans[h][w + 1]

    for h in range(H):
        print(*ans[h], sep=" ")


if __name__ == "__main__":
    main()


Measured memory_bytes: 7572
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT false

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}


void solve(void)
{ 
  int A,B;
  cin>>A>>B;
  if(A+B>=10)
  {
    cout<<"error"<<endl;
  }
  else
  {
    cout<<A+B<<endl;
  }
  
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;}

vector<string> s{};

string solve(vector<string> keys, int ind, int depth){
    int indent = INT_MAX;
    while (true){
        if (ind >= s.size())
            return "no such property";
        for (int i = 0; i < indent; i++)
            if (s[ind][i] != ' '){
                if (indent == INT_MAX) {
                    indent = i;
                    continue;
                }
                return "no such property";
            }
        string key = "";
        if (s[ind][indent] == ' ') {
            ind++;
            continue;
        }
        int beginInd;
        for (int i = indent; i < s[ind].size(); i++){
            if (s[ind][i] == ':') {
                beginInd = i + 2;
                break;
            }
            key += s[ind][i];
        }
        if (keys[0] != key) {
            ind++;
            continue;
        }
        if (beginInd >= s[ind].size()){
            if (keys.size() == 1) return "object";
            vector<string> newkeys{};
            for (int i = 1; i < keys.size(); i++)
                newkeys.push_back(keys[i]);
            return solve(newkeys, ind + 1, depth + 1);
        }
        if (keys.size() >= 2)
            return "no such property";
        string res = "string \"";
        for (int i = beginInd; i < s[ind].size(); i++)
            res += s[ind][i];
        res += "\"";
        return res;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    //cout << setprecision(15) << fixed;
    string query;
    getline(cin, query);
    string t;
    while (getline(cin, t)){
        var copied = t;
        s.push_back(copied);
    }
    vector<string> keys;

    string current = "";
    for (int i = 1; i < query.size(); i++){
        if (query[i] == '.'){
            keys.push_back(current);
            current = "";
        }
        else current += query[i];
    }
    keys.push_back(current);

    cout << solve(keys, 0, 0) << endl;

    return 0;
}




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

#define vec vector
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef double d;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;
typedef unsigned int ui;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    vector <pair<int, pair<int, int> > > v(n);
    for (auto &it : v)
        cin >> it.second.first;
    for (auto &it : v)
    {
        cin >> it.second.second;
        it.first = it.second.first - it.second.second;
    }
    int x = 0;
    for (int i = 0; i < n; i++)
    {
        x += max(0, v[i].first);
    }
    cout << x;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int H = 19, W = 15;
string s[H];

const int INF = 19191919;
vector<pi> black;
map<pi,int> b2id;
int n;

map<pi,int> dp[1<<20];
int dfs(int mask, pi pos){
    if(pos.fi >=H) return 0;
    if(pos.se<0 || W<=pos.se) return INF;
    if(pos.fi == H-1) return 0;

    if(dp[mask].count(pos)) return dp[mask][pos];

    set<pi> rem;
    rep(i,n)if(!(mask>>i&1)) rem.insert(black[i]);

    int ret = INF;
    for(int dy=-1; dy<=1; ++dy)for(int dx=-1; dx<=1; ++dx){
        if(dy==0 && dx==0) continue;

        pi nx = pos;
        nx.fi += dy;
        nx.se += dx;
        if(!rem.count(nx)) continue;

        int nmask = mask;
        while(rem.count(nx)){
            nmask |= 1<<b2id[nx];
            nx.fi += dy;
            nx.se += dx;
        }

        ret = min(ret, dfs(nmask, nx)+1);
    }

    return dp[mask][pos] = ret;
}

int main(){
    rep(i,H) cin >>s[i];

    pi white;
    rep(i,H)rep(j,W){
        if(s[i][j]=='O') white = {i,j};
        if(s[i][j]=='X') black.pb({i,j});
    }
    n = black.size();

    rep(i,n) b2id[black[i]] = i;

    int ans = dfs(0, white);
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 57516
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
  	cin.tie(nullptr);
  
    int n;
    cin >> n;
    vector<vector<int>> pos(200005);
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        pos[a].push_back(i);
    }
    
    if(pos[1].size() == 0){
        cout << -1 << endl;
        return 0;
    }
    
    int now_pos = pos[1][0];
    for(int i = 2; i < 200005; ++i){
        auto it = upper_bound(pos[i].begin(), pos[i].end(), now_pos);
        if(it == pos[i].end()){
            cout << n - i + 1 << endl;
            return 0;
        }
        now_pos = *it;
    }
}

Measured memory_bytes: 11264
#include <iostream>
#include <limits.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d;
    
    scanf("%d %d %d %d",&a, &b, &c, &d);
    
    long max = LONG_MIN;
    
    max = (long(a)*c > max)? long(a)*c:max;
    max = (long(a)*d > max)? long(a)*d:max;
    max = (long(b)*c > max)? long(b)*c:max;
    max = (long(b)*d > max)? long(b)*d:max;
    
    printf("%ld\n", max);
}


Measured memory_bytes: 3828
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <utility>

using namespace std;

void chomp(string *str) {
  if ((*str)[str->size() - 1] == '\n') { str->erase(str->end() - 1); }
}

int main() {
  string word;
  typedef pair<string, int> WordFrequency;
  unordered_map<string, int> word_frequencies;
  while (cin >> word) { ++word_frequencies[word]; }

  auto most_frequent_word = accumulate(
      word_frequencies.begin(),
      word_frequencies.end(),
      WordFrequency(),
      [&](const WordFrequency& a, const WordFrequency& b){
        return a.second > b.second ? a : b;
      }).first;
  auto longuest_word = accumulate(
      word_frequencies.begin(),
      word_frequencies.end(),
      WordFrequency(),
      [&](const WordFrequency& a, const WordFrequency& b){
        return a.first.size() > b.first.size() ? a : b;
      }).first;

  cout << most_frequent_word << ' ' << longuest_word << endl;

  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int n;
	cin>>n;
	int ans=0;

	for(int i=1;i<=n;i+=2){
		int cnt=0;
		for(int j=1;j<=i;j++){
			if(i%j==0)cnt++;
		}
		if(cnt==8)ans++;
	}

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


Measured memory_bytes: 256
//Subhash Suman
//Date: 10/02/19 ; Day: Sunday ; Time: 18::03::06 
//Description : 

#include<bits/stdc++.h>
#define ll long long int
#define MAX INT_MAX
#define MIN INT_MIN
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>

using namespace std;
const int N = 1e5+5;
int dp[N],arr[N];
int n;


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>arr[i];
    }
    dp[1] = 0;
    dp[2] = abs(arr[1]-arr[2]);
    for(int i = 3; i <= n; i++){
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var n int = nextInt()
	var A []int
	for i := 0; i < n; i++ {
		A = append(A, nextInt())
	}

	//1 bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A
	//2   flag = 1 // 逆の隣接要素が存在する
	//3   while flag
	//4     flag = 0
	//5     for j が N-1 から 1 まで
	//6       if A[j] < A[j-1]
	//7         A[j] と A[j-1] を交換
	//8         flag = 1
	var count = 0
	var flag = true
	for flag {
		flag = false
		for i := n - 1; i >= 1; i-- {
		
			if A[i] < A[i-1] {
				A[i], A[i-1] = A[i-1], A[i]
				count++
				flag = true
			}
		}
	}

	fprintArray(A)

	fmt.Fprintln(wtr,fmt.Sprint(count))
	_ = wtr.Flush()

}

func fprintArray(arr []int) {
    for i := 0; i < len(arr); i++ {
        if i == 0 {
            fmt.Fprintf(wtr,"%d", arr[i])
        } else {
            fmt.Fprintf(wtr," %d", arr[i])
        }
    }
    fmt.Fprintln(wtr)
}


Measured memory_bytes: 1148
#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 N;
vector<int> A;
int X[200000+10];
int Ans;
int main(void) {
    cin>>N;

    A.push_back(0);
    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        A.push_back(a);
    }

    for(int i = N;i >= 1;i--) {
        int sum = 0;
        for(int j = 1;i*j <= N;j++) {
            sum += X[i*j];
        }
        if(sum % 2 != A[i]) {
            X[i] = 1;
            Ans++;
        }
    }

    cout<<Ans<<endl;
    if(Ans != 0) {
        for(int i = 1;i <= N;i++) {
            if(X[i] == 1) {
                cout<<i<<" ";
            }
        }
        cout<<endl;
    }

    return 0;
}



Measured memory_bytes: 2548
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
int main(){
    long long x,y,z,x1,y1,z1;
    int temp = -1;
    scanf("%lld %lld %lld",&x,&y,&z);
    for(int i = 1;;i++){
            temp++;
            if(temp >= 100000){
                    printf("-1");
                    break;
            }
            else if(x%2==1||y%2==1||z%2==1){
                printf("%d",temp);
                    break;
            }
            else
                {x1 = x/2;y1 = y/2;z1 = z/2;
                x = y1 + z1;y = x1 + z1; z = x1 + y1;}
    }
}


Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    let mut itr = is.split_whitespace().map(|e| e.parse::<i64>().unwrap());
    println!("{}", itr.next().unwrap() * itr.next().unwrap());
}


Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int a,b,x;
	cin >> a >> b >> x;
	if(x-a >= 0 && x-a <= b) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def gcd(a, b):
    if a < b:
        a, b = b, a
    while b!=0:
        c = b
        b = a % b
        a = c
    return a

def lcm(a, b, g):
    return a * b / g

def main():
    for line in sys.stdin:
        a, b = map(int, line.split())
        ng = gcd(a, b)
        nl = lcm(a, b, ng)
        print('{0:d} {1:d}'.format(int(ng), int(nl)))

if __name__ == '__main__':
    main()

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

typedef long long int LL;
const int N = 2e5 + 5;
const int MOD = 1000000007;

#define x first
#define y second

int r , c , k;
pair <int,int> a[ N ];
LL Fact[ N ];
LL reach[ N ];
LL modInv[ N ];

bool cmp( pair <int,int> x , pair <int,int> y ) {
        if( x.first == y.first ) return x.second < y.second;
        return x.first < y.first;
}
LL BigMod( LL b , LL p , LL mod ) {
        LL res = 1 % mod , x = b % mod;
        while ( p ) {
                if ( p&1 ) res = ( res * x ) % mod;
                x = ( x * x ) % mod;
                p >>= 1;
        }
        return ( res % mod );
}
LL ModInv( LL val , LL mod ) {
        return BigMod( val , mod - 2 , mod );
}
void preCalc( ) {
        Fact[0] = 1LL;
        for( int i = 1; i < 2*N; i++ ){
                Fact[i] = ( Fact[i-1] % MOD * i %MOD ) % MOD;
        }
        modInv[N-1] = ModInv( Fact[N-1] , MOD );
        for( int i = N-2; i >= 0; i-- ) {
                modInv[i] = ( modInv[i+1] % MOD * (i+1) % MOD ) % MOD;
        }
}
LL nCr( LL n , LL r ) {
        if( r > n ) return 0;
        LL val = Fact[n];
        val = ( val % MOD * modInv[r] % MOD ) % MOD;
        val = ( val % MOD * modInv[n-r] % MOD ) % MOD;
        return val;
}
LL Ways( int x1 , int y1 , int x2 , int y2 ) {
        if( x1 > x2 || y1 > y2 ) return 0;
        LL step = ( x2 - x1 + y2 - y1 );
        LL r = ( y2 - y1 );
        return nCr( step , r );
}
void computeDP( ) {
        reach[1] = Ways( 1 , 1 , a[1].x , a[1].y );
        for( int i = 2; i <= k; i++ ) {
                reach[i] = Ways( 1 , 1 , a[i].x , a[i].y );
                LL subtract = 0;
                for( int j = 1; j < i; j++ ) {
                        subtract += reach[j] * Ways( a[j].x , a[j].y , a[i].x , a[i].y );
                        subtract = subtract % MOD;
                }
                reach[i] -= subtract , reach[i] += MOD , reach[i] %= MOD;
        }
}
int main( int argc , char const *argv[] ) {
        preCalc( );
        scanf("%d %d %d",&r,&c,&k);
        for( int i = 1; i <= k; i++ ) scanf("%d %d",&a[i].x,&a[i].y);
        sort( a+1 , a+k+1 , cmp );
        computeDP( );
        LL ans = Ways( 1 , 1 , r , c );
        LL subtract = 0;
        for( int i = 1; i <= k; i++ ) {
                subtract += reach[i] * Ways( a[i].x , a[i].y , r , c );
                subtract %= MOD;
        }
        ans -= subtract , ans += MOD , ans %= MOD;
        printf("%lld\n",ans);
        return 0;
}









Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<int> a(3*N);
	rep(i,3*N){
		cin>>a[i];
	}
	sort(all(a));
	print(a);
	ll ans = 0;
	for (int i = N; i < 3*N; i+=2){
		ans+=a[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1408
n, m = map(int, input().split())
coin = list(map(int, input().split()))
dp = [float("inf") for i in range(n+1)]
dp[0] = 0
for i in range(n+1):
    for j in coin:
        if i+j <= n:
            dp[i+j] = min(dp[i+j], dp[i]+1)
print(dp[n])


Measured memory_bytes: 7392
#include <iostream>
using namespace std;
int main() {
  int N, Y;
  cin >> N >> Y;

  bool exit = false;

  for (int x = 0; x <= N; ++x) {
    for (int y = 0; y <= N; ++y) {
      int z = N - x - y;
      if (z < 0)
        break;
      int sum = 10000 * x + 5000 * y + 1000 * z;
      if (sum == Y) {
        cout << x << " " << y << " " << z << endl;
        exit = true;
        break;
      }
    }
    if (exit) {
      break;
    }
  }
  if (!exit) {
    cout << "-1 -1 -1" << endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
const int N = 2e3 + 5, M = 2e5;
int main()
{
    Hello
    ll a, b, k;
    cin >> a >> b >> k;
    ll ansA = a, ansB = b;
    if(k >= a){
        ansA = 0;
        ansB = max(1ll*0, b - (k - a));
    }
    else
        ansA -= k;
    cout << ansA << " " << ansB;
    return 0;
}

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

int main()
{
	long long n, a, b;
	scanf("%lld%lld%lld", &n, &a, &b);
	if((b - a) % 2 == 0) printf("%lld", (b - a) / 2);
	else printf("%lld", min(a - 1, n - b) + 1 + (b - a) / 2);
	return 0;
}




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

using namespace std;

using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second
#define ADD(a,b) (((u64)a + b)%MOD)
#define MUL(a,b) (((u64)a * b)%MOD)

constexpr int MOD = 998244353;

i64 strictSqrt(i64 n) {
  i64 r = std::sqrt(n);
  i64 d = abs(n - r * r);
  i64 d2;

  while (d2 = abs(n - (r + 1) * (r + 1)) < d) {
    r++;
    d = d2;
  }
  while (d2 = abs(n - (r - 1) * (r - 1)) < d) {
    r--;
    d = d2;
  }
  return r;
}

template < typename T >
constexpr T sqrt(T s)
{
  T x = s / 2.0;
  T prev = 0.0;

  while (x != prev)
  {
    prev = x;
    x = (x + s / x) / 2.0;
  }
  return x;
}

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

  int a, b, c;
  cin >> a >> b >> c;

  // a + 2sqrt(ab) + b < c

  bool judge = (long double)a + b + 2 * std::sqrt((long double)((i64)a * b)) < c;
  
  cout << (judge ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	set<int> s;
	rep(i, 3) {
		int x; cin >> x;
		s.insert(x);
	}
	dbl(*rbegin(s));
	s.erase(*rbegin(s));
	db(*begin(s)); dbl(*rbegin(s));
	int a = *begin(s), b = *rbegin(s);
	cout << a * b / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define i64 long long int
int n;
i64 a[100100], sum[100100], sum2[100100];
int main(){
	int q;i64 X;
	ios::sync_with_stdio(false);
	cin >> n >> q;
	for(int i=1; i<=n; i++)cin >> a[i];
	if(n % 2 == 1){
		for(int i=n; i>=1; i--)a[i+1] = a[i];
		a[1] = (i64)(-2e9);
		++n;
	}
	a[0] = (i64)(-2e10);
	for(int i=1; i<=n; i++){
		sum[i] = a[i] + sum[i-1];
		sum2[i] = a[i] + (i<=2?0:sum2[i-2]);
	}
	while(q--){
		cin >> X;
		int hi = (a+n+1) - (lower_bound(a+1, a+n+1, X)), lo = (hi + 1) / 2;
		while(lo != hi){
			int mi = (lo + hi)/2;
			if(n - mi * 2 >= 0 && X - a[n - mi * 2] <= a[n - mi] - X)
				lo = mi + 1;
			else
				hi = mi;
		}
		cout << sum[n] - sum[n - lo] + sum2[n - lo * 2] << endl;
	}
	return 0;
}


Measured memory_bytes: 4096
n, m = list(map(int, input().split()))
p = [input().split() for i in range(m)]

s = {i + 1 for i in range(n)}

ac = 0
wa = {i + 1:[0, False] for i in range(n)}


for i in range(m):
  if int(p[i][0]) in s:
    if p[i][1] == 'WA':
      wa[int(p[i][0])][0] += 1
    else:
      ac += 1
      s.discard(int(p[i][0]))
      wa[int(p[i][0])][1] = True
      
wa_wa = 0
for i in range(1, n + 1):
  if wa[i][1]:
    wa_wa += wa[i][0]
print(ac, wa_wa)


Measured memory_bytes: 60032
F = [int(n) for n in input().split()]
N = int(input())

class Dice():

    def __init__(self,faces):
        self.top = faces[0]
        self.south = faces[1]
        self.east = faces[2]
        self.west = faces[3]
        self.north = faces[4]
        self.bottom = faces[5]

    def rotate(self,d):
        if d == "N":
            tmp = self.top
            self.top = self.south
            self.south = self.bottom
            self.bottom = self.north
            self.north = tmp

        elif d == "S":
            tmp = self.top
            self.top = self.north
            self.north = self.bottom
            self.bottom = self.south
            self.south = tmp

        elif d == "E":
            tmp = self.top
            self.top = self.west
            self.west = self.bottom
            self.bottom = self.east
            self.east = tmp

        elif d == "W":
            tmp = self.top
            self.top = self.east
            self.east = self.bottom
            self.bottom = self.west
            self.west = tmp



    def setTop(self,top):
        if self.south == top:
            self.rotate("N")
        elif self.east == top:
            self.rotate("W")
        elif self.west == top:
            self.rotate("E")
        elif self.north == top:
            self.rotate("S")
        elif self.bottom == top:
            self.rotate("N")
            self.rotate("N")
        

    def setFront(self,front):
        if self.south == front:
            return self.east
        elif self.east == front:
            return self.north
        elif self.west == front:
            return self.south
        elif self.north == front:
            return self.west

    def get_top_value(self):
        return self.top



D = Dice(F)
# for d in D:
#     N.rotate(d)


for _ in range(N):
    top,front = map(int,input().split())
    D.setTop(top)
    print(D.setFront(front))


Measured memory_bytes: 5608
import bisect

n,m=map(int,input().split())
p=[]
y=[]
yd=[[] for _ in range(n+1)]
for i in range(m):
    pp,yy=map(int,input().split())
    p.append(pp)
    y.append(yy)
    yd[p[i]].append(y[i])
for i in range(n):
    yd[i+1].sort()
for i in range(m):
    x=p[i]*1000000+bisect.bisect_left(yd[p[i]],y[i])+1
    x=str(x)
    print("0"*(12-len(x))+x)


Measured memory_bytes: 24116
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
const int N=1e5+5;

int main(){
char s[N];
int k;
cin>>k>>s;
if(strlen(s)<=k)cout<<s;
else {
    for(int i=0;i<k;i++)cout<<s[i];
    cout<<"...";
}


return 0;}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, M, X, Y, a;
	vector<int> x, y;

	cin >> N;
	cin >> M;
	cin >> X;
	cin >> Y;
	for (int i = 0; i < N; i++)
	{
		cin >> a;
		x.push_back(a);
	}
	for (int i = 0; i < M; i++)
	{
		cin >> a;
		y.push_back(a);
	}

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	if (x.back() < y.front() && x.back() < Y && X < y.front())
		cout << "No War" << endl;
	else
		cout << "War" << endl;
}

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

int main(){
  int n; cin >> n;
  int scoreT = 0, scoreH = 0;
  for(int i=0; i<n; i++){
    string T; cin >> T;
    string H; cin >> H;
    if(T > H)
      scoreT += 3;
    else if(T == H){
      scoreT++;
      scoreH++;
    }else
      scoreH += 3;
  }

  cout << scoreT << " " << scoreH << endl;
  
  return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10010;
char str[100];
int n;
int main(){
    int n;
    scanf("%d",&n);

    int a = 0, b = 0, same = 0;
    int ans = 0;
    for (int i=1;i<=n;i++){
        scanf("%s",str);
        int len = strlen(str);
        for(int j=0;j<len-1;j++) if (str[j] == 'A' && str[j+1] == 'B') ans++;
        if (str[0] == 'B') b++;
        if (str[len-1] == 'A') a++;
        if (str[0] == 'B' && str[len-1] == 'A') same++;
    }
//    cout<<a<<" "<<b<<" "<<same<<endl;
    if (a > 0 && b > 0){
        ans += min(a,b);
        if (a == b && a == same) ans--;
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int n;
	const int t = 86400;
	
	while( scanf("%d",&n) , n ){
		int table[t] = {};
		for(int i=0 ; i<n ; ++i ){
			int h1,m1,s1,h2,m2,s2,start,end;
			scanf("%d:%d:%d %d:%d:%d", &h1 , &m1 , &s1 , &h2 , &m2 , &s2 );
			start = s1 + m1*60 + h1*60*60 + 1;
			end   = s2 + m2*60 + h2*60*60;
			for(int j = start ; j <= end ; ++j ){
				table[j]++;
			}
		}
		int ans = 0;
		for(int i=0 ; i<t ; ++i ){
			ans = max( ans , table[i] );
		}
		printf("%d\n", ans );
		
	}
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
#include <chrono>
#include <regex>
using namespace std;
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define ll long long
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(0); 
#define Ichar(_x) char _x=_getchar_nolock();
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define Istring(_x) string _x;cin>>_x; 
#define inc(a,b,x)(x)>=a && (x)<=b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
//#define DEBUG
template<typename T>
int sUm(T* t1, T* t2)
{
	int s = 0;

	for (T* pi = t1; pi != t2; pi++)
	{
		s += *pi;
	}
	return s;
}

ll modo(ll a)
{
	return a % (int)(1e9+7);
}

int main()
{
	string a, b, c;
	std::cin >> a >> b >>c;
	std::cout << a[0] << b[1] << c[2];
}





Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using  namespace std;

int main(void)
{
        int a, b;
        int r;
        int d;
        double f;

        //Input a, b
        cin >> a >> b;

        d = a / b;
        r = a % b;
        f = (double)a / b;

        printf("%d %d %f\n", d, r, f);

        return 0;
}

Measured memory_bytes: 1184
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    S = input()
    N = len(S)
    w = int(input())
    ans = []
    for i in range(0, N, w):
        ans.append(S[i])

    print(*ans, sep="")


if __name__ == "__main__":
    main()


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

int64_t gcd(int64_t a,int64_t b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}

int64_t GCD(int64_t a,int64_t b,int64_t c){
  return gcd(gcd(a,b),c);
}

int main(){
  int K;
  cin >> K;
  int64_t ans=0;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int k=1;k<=K;k++){
        ans+=GCD(i,j,k);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl '\n'
const int maxn=2*1e5+5;

int main()
{
int x;
cin>>x;
string h;
cin>>h;
stack<char> s;
s.push(h[0]);
for(int i=1;i<x;i++)
{
    if(!s.empty() && s.top()!=h[i])
    {
        s.push(h[i]);

    }
}
cout<<s.size()<<endl;

        return 0;
}


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

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
#define MOD 1000000007

using namespace std;

using ll = long long;
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

typedef stack<ll> llStack;
typedef queue<ll> llQueue;
typedef vector<ll> llVector;
typedef list<ll> llList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  string S;
  cin >> S;
  
  if(S == "ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}

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

using namespace std;
typedef long long LL;

#define MAXN 100001
#define MOD 1000000007


int main(int argc, char** argv) {
#ifdef OJ	
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    std::ios::sync_with_stdio(false);

    int a,b,c;
    LL K;
    cin >> a >> b >> c >> K;
    
    if (K%2 == 0)
        cout << a - b << endl;
    else
        cout << b - a << endl;

    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MN 100000
#define MOD 1000000007
char s[MN+5];
int S[MN+5],t[MN+5][3],f[MN+5];
inline void rw(int&x,int y){if((x+=y)>=MOD)x-=MOD;}
int main()
{
	int n,i,j,ans=0;
	scanf("%s",s+1);n=strlen(s+1); 
	for(i=1;i<n;++i)if(s[i]==s[i+1])break;
	if(i==n)return 0*puts("1");
	for(i=1;i<=n;++i)S[i]=(S[i-1]+s[i]-'a'+1)%3;
	for(j=0;j<3;++j)t[n+1][j]=n+1;
	for(i=n;i;t[i][S[i]]=i,--i)for(j=0;j<3;++j)t[i][j]=t[i+1][j];
	for(f[0]=i=1;i<=n;(S[n]-S[i])%3?0:(rw(ans,f[i]),0),++i)
		for(j=1;j<3;++j)rw(f[t[i][(S[i-1]+j)%3]],f[i-1]);
	printf("%d",ans);
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2);
}


int main()
{
	vector<string> V(7);
	V[0]="SUN";
	V[1]="MON";
	V[2]="TUE";
	V[3]="WED";
	V[4]="THU";
	V[5]="FRI";
	V[6]="SAT";
	string s;
	cin>>s;
	for(int i=0;i<7;i++)
	{
		if(s==V[i]) cout<<(7-i)<<endl;
	}
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n  = bin(I())[2:]
dp0, dp1, dp2 = 1, 0, 0
for d in n:
    if d == '1':
        dp0, dp1, dp2 = dp0 % mod, (dp0 + dp1) % mod, (dp1 * 2 + dp2 * 3) % mod
    else:
        dp0, dp1, dp2 = (dp0 + dp1) % mod, dp1 % mod, (dp1 + dp2 * 3) % mod



print((dp0 + dp1 + dp2) % mod)



Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
constexpr char nl = '\n';
template<class T> istream& operator>>(istream& in, vector<T>& vs) { for (T& v :vs) in >> v; return in; }

int main() {
    int N;
    cin >> N;
    vector<int> next(N);
    cin >> next;
    for (int& n : next) n--;
    vector<int> distance(N, -1);
    distance[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        if (distance[next[v]] == -1) {
            distance[next[v]] = distance[v] + 1;
            q.push(next[v]);
        }
    }
    cout << distance[1] << nl;
}


Measured memory_bytes: 1024
import Data.List
import Data.Char
import Data.Maybe
import qualified Data.ByteString.Char8 as BS8

dig_impl 0 r = r
dig_impl n r = dig_impl (div n 10) (r + 1)

dig n = dig_impl n 0

main :: IO ()
main = do
    [a, b] <- unfoldr (BS8.readInteger . BS8.dropWhile isSpace) <$> BS8.getLine

    print $ maximum [a + b, a - b, a * b]


Measured memory_bytes: 380
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

char g[805][805];
int h,w,k,ans = MAX;
int vis[805][805];

queue<P> q;

void bfs(P z) {
    q.push(z);
    vis[z.first][z.second] = 1;
    while(!q.empty()) {
        P e = q.front();
        q.pop();
        int u = e.first,v = e.second;
        if(vis[u][v] > k + 1 || g[u][v] == '#') continue;
        int d = min(min(u,h - 1 - u),min(v,w - 1 - v));
        if(d == 0) ans = 1;
        else ans = min(ans,d / k + (d % k != 0) + 1);
        if(u > 0 && !vis[u - 1][v]) {
            vis[u - 1][v] = vis[u][v] + 1;
            q.push(P(u - 1,v));
        }
        if(u + 1 < h && !vis[u + 1][v]) {
            vis[u + 1][v] = vis[u][v] + 1;
            q.push(P(u + 1,v));
        }
        if(v > 0 && !vis[u][v - 1]) {
            vis[u][v - 1] = vis[u][v] + 1;
            q.push(P(u,v - 1));
        }
        if(v + 1 < w && !vis[u][v + 1]) {
            vis[u][v + 1] = vis[u][v] + 1;
            q.push(P(u,v + 1));
        }
    }
}


int main() {
    int i,j;
    int u,v;
    scanf("%d%d%d",&h,&w,&k);
    for(i = 0; i < h; i++) {
        scanf("%s",g[i]);
        for(j = 0; j < w; j++) {
            if(g[i][j] == 'S') {
                u = i;
                v = j;
            }
        }
    }
    bfs(P(u,v));
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3456
N = int(input())
 
MOD = 10**9 + 7
 
if N==1:
    print(0)
elif N==2:
    print(2)
else:
    ans = pow(10,N,MOD) - 2*pow(9,N,MOD) + pow(8,N,MOD)
    ans = ans%MOD
    print(ans)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const double PI=acos(-1);

int N;
int X[222222],Y[222222];

const int INF=1001001001;
int dp[222222];

signed main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    cin>>N;
    rep(i,N)cin>>X[i]>>Y[i];

    if(x1>x2){
        x1*=-1;x2*=-1;
        rep(i,N)X[i]*=-1;
    }
    if(y1>y2){
        y1*=-1;y2*=-1;
        rep(i,N)Y[i]*=-1;
    }

    double ans=(y2-y1+x2-x1)*100;
        vpint ps;
        rep(i,N){
            if(x1<=X[i]&&X[i]<=x2&&y1<=Y[i]&&Y[i]<=y2)ps.pb({X[i],Y[i]});
        }
        sort(all(ps));
        int n=ps.size();
        vint A(n);
        rep(i,n)A[i]=ps[i].se;

        fill_n(dp,n,INF);
        for(int i=0;i<n;i++){
            *lower_bound(dp,dp+n,A[i])=A[i];
        }
        int latte=lower_bound(dp,dp+n,INF)-dp;
        ans+=(-20+PI/2*10)*latte;
        if(x2-x1+1==latte||y2-y1+1==latte){
            ans+=-(-20+PI/2*10)+(-20+PI*10);
        }


    printf("%.20f\n",ans);
    return 0;
}


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

int main() {
 
  int N,K;
  cin >> N >> K;
  
  vector<int> l(N);
  for(int i=0; i<N; i++){
    cin >> l.at(i);
  }
  
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  
  int ans = 0;
  for(int i=0; i<K; i++){
    ans += l.at(i);
  }
  
  cout << ans << endl;
  
}


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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> v(n);
	for (auto &x : v){
		cin >> x;
	}
	int res = 0;
	int i = 1;
	while (i < n - 1){
		int tmp = v[i] + v[i-1] + v[i+1];
		int maxx = max(v[i], max(v[i-1], v[i+1]));
		int minn = min(v[i], min(v[i-1], v[i+1]));		
		if (tmp - maxx - minn == v[i]){
			++res;
		}       
		++i;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.Math.*;

public class Main{ 
    
    public static void main(String[] args)throws IOException{
	try{
	BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
	String line="";
	line=br.readLine();
      	StringTokenizer st=new StringTokenizer(line);
	int i=0;
	int n = st.countTokens();
	String[] str = new String[n];
	while(st.hasMoreTokens()){
	    str[i]=st.nextToken();
	    i++;
	}
	int key=0,cntmax=0;
	for(i =0;i<n-1;i++){
	    int cnt=0,result=0;
	    for(int j=i+1;j<n;j++){
		if(str[i].equals(str[j])){
		    cnt++;
		    if(cnt>cntmax){
			cntmax=cnt;
			key=i;
		    }		    
		}
	    }
	}
	int l=0;
	for(i=0;i<n;i++)
	    if(str[l].length()<str[i].length())
		l=i;
	System.out.println(str[key]+" "+str[l]);
	}catch(ArrayIndexOutOfBoundsException e){
	    System.out.println();
	}
    }

}

Measured memory_bytes: 15024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int h,w;
  scanf("%d %d",&h,&w);
  char s[w+1];
  FOR(h){
    scanf("%s",s);
    FORJ(2)PRS(s);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
using llong = long long;
using ullong = unsigned long long;

int main() {
    int N ;
    cin >> N ;
    ullong sum = 0;
    vector<int> d(N);
    for(auto &x:d) cin >> x;
    for(int i=0;i<N;++i){
      for(int j=i+1;j<N;++j){
        sum += d[i]*d[j];
      }
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
N,K=gets.split.map(&:to_i)
ary = gets.split.map(&:to_i)

h = {}
ary.each do |elm|
  if h[elm].nil?
    h[elm] = 1
  else
    h[elm] += 1
  end
end
ary_tmp = h.sort_by { |_, v| v }
count = 0
key_len = ary_tmp.length
while K < key_len
  elm = ary_tmp.shift
  count += elm[1]
  key_len -= 1
end
puts count


Measured memory_bytes: 40960
a=[]
n=int(input())
i=0
while(n>i):
    b=int(input())
    a.append(b)
    i+=1
score=-1000000000
mini = a[0]
for i in a[1:]:
    if(i-mini>score):
        score = i-mini
    if(mini>i):
        mini=i
    

print(score)

Measured memory_bytes: 17188
#include<bits/stdc++.h>
using namespace std;
bool valid(int n,map<int,bool>&m)
{
    while(n)
    {
        if(m[n%10]==true)
            return false;
        n/=10;
    }
    return true;
}
int main()
{
    int n;
    int k;
    cin>>n>>k;
    map<int,bool>m;
    for(int i=0;i<k;i++)
    {
        int temp;
        cin>>temp;
        m[temp]=true;
    }
    for(int i=n;;i++)
    {
        if(valid(i,m))
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256