akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int H, W;
    cin >> H >> W;
    set<pii> st;
    multiset<int> mst;
    for (int i = 0; i < W; ++i) {
        st.emplace((pii){i, i});
        mst.emplace(0);
    }

    for (int i = 0; i < H; ++i) {
        int A, B;
        cin >> A >> B;
        A--, B--;

        auto itr = st.lower_bound({A, 0});
        int maidx = -1;
        while (itr != st.end() && itr->first <= B) {
            mst.erase(mst.find(itr->first - itr->second));
            maidx = itr->second;
            auto citr = itr;
            ++itr;
            st.erase(citr);
        }

        if (B + 1 < W && ~maidx) {
            st.emplace((pii){B + 1, maidx});
            mst.emplace(B + 1 - maidx);
        }

        if (mst.empty())
            cout << -1 << '\n';
        else
            cout << *mst.begin() + i + 1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 22352
fn input() -> i32 {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let mut integers = s.split_whitespace();
    let integer: i32 = integers.next().unwrap().parse().unwrap();
    integer
}
fn input_char() -> char {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let ch: char = {
        let mut tmp: char = 'a';
        for c in s.chars() {
            tmp = c
        }
        tmp
    };
    ch
}

fn main() {
    let n:i32 = input();
    let p: Vec<i32> = {
        let s = {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            s.trim_right().to_owned()
        };
        let integers: Vec<&str> = s.split_whitespace().collect();
        let mut vector = Vec::new();
        let mut tmp: i32;
        for element in integers {
            tmp = element.parse().unwrap();
            vector.push(tmp);
        }
        vector
    };
    // dbg!(p);
    
    let mut can: bool;
    let mut cnt = 0;
    let mut a: i32;
    let mut b: i32;
    let mut c: i32;
    
    for i in 0..(n-2) as usize {
        // dbg!(i);
        can = false;
        a = p[i];
        b = p[i+1];
        c = p[i+2];
        if a < b && b <= c {
            can = true;
        }
        if c < b && b <= a {
            can = true;
        }
        if can {
            cnt += 1;
        }
    }

    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

int main(){
	char strs[201];
	char strd[101];
	char strp[101];

	scanf("%s",strs);
	scanf("%s",strp);

	/*strs?????????str?????£?????????strss?????????*/
	strcpy(strd,strs);
	strcat(strs,strd);

	if( strstr(strs,strp) ){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 540
#include<iostream>
#include<vector>
using namespace std;
int main(){
  
  int n,ans=0;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;++i){
    cin>>a[i];
    if((i+1)%2==1 and a[i]%2==1)
      ++ans;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3572
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy


#X = str(input()).split()
#a = [int(x) for x in input().split()]


NR = str(input()).split()
N = int(NR[0])
R = int(NR[1])
if(N>=10):
  ans = R
else:
  ans = R+100*(10-N)


print(ans)



Measured memory_bytes: 38764
x = int(input())
ans = 8
if x <= 599:
    ans = 8
elif x <= 799:
    ans = 7
elif x <= 999:
    ans = 6
elif x <= 1199:
    ans = 5
elif x <= 1399:
    ans = 4
elif x <= 1599:
    ans = 3
elif x <= 1799:
    ans = 2
else:
    ans = 1
print(ans)

Measured memory_bytes: 61620
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
    char a[100000];
    int i,ans,sum=0,len;
   scanf("%s",a);
    ans=0;
    len=strlen(a);
    for(i=0; i<=len-1; i++)
    {
        if(a[i]=='A'||a[i]=='T'||a[i]=='C'||a[i]=='G')
        {
            ans++;
        }
        else
        {
            if(ans>sum)
            {
                sum=ans;
            }
            ans=0;
        }
    }
    if(sum<ans)
        sum=ans;
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

int main(void){
	char c;
	while((c=getchar())!=10){
		putchar(c=='?'?'D':c);
	}
	putchar(10);
}


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

int main(){
  
  int a,b;
  cin >> a >> b;
  int ans;
  //差から、1本目(a)の塔の高さを求める
  int dif;
  dif=b-a;

  int height_a;
  height_a=(dif*(dif-1))/2;

  ans=height_a-a;

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

Measured memory_bytes: 3556
#include <bits/stdc++.h>
  using namespace std;
  #define END '\n'
  #define int long long
  #define pb push_back
  #define pii pair<int, int>
  #define ff first
  #define ss second
  #define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  #define loop(i, a, b) for(int i = (a); i < (b); i++)
  #define loopb(i, b, a) for(int i = (b); i > (a); --i)   
  const int mod = 1e9+7;
  const int inf = 5e18;
  const int mod1 = 998244353;
  
  void solve()
   {
     int n;
     cin>>n;
     vector<int> a(n),b(n),cnt(n+1,0);
     loop(i,0,n)
     {
      cin>>a[i];
      cnt[a[i]]++;
     }
     loop(i,0,n)
      {
        cin>>b[i];
        cnt[b[i]]++;
      }
     loop(i,0,n+1)
      if(cnt[i] > n)
         {
          cout<<"No";
          return;
         }
     reverse(b.begin(), b.end());
     int l = 0,r = n-1;
     loop(i,0,n)
      {
        if(a[i] == b[i])
           {
            if(b[l] != a[i] && a[l] != a[i])
               {
                swap(b[l],b[i]);
                l++;
               }
            else
               {
                swap(b[r],b[i]);
                r--;
               }
           }
      }
     cout<<"Yes"<<END;
     for(int x : b)
       cout<<x<<" ";
   }
  int32_t main()
   {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
    /* int t;
     cin>>t;
     while(t--)*/
       solve();
   // cerr<<END<<1.0*clock()/CLOCKS_PER_SEC;
    return 0;
  } 

Measured memory_bytes: 7924
H, W = list(map(int, input().split(' ')))
if H > 1 and W > 1:
    cell_num = (int(H / 2) * 2) * (int(W / 2) * 2) / 2
    if H % 2 == 1:
        cell_num += int((W + 1) / 2)
    if W % 2 == 1:
        cell_num += int(H / 2)
else:
    cell_num = 1
print(int(cell_num))


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<int, string>    P;

int main() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    reverse(ALL(s));
    
    /* m個1が連続していたら無理 */
    int renzoku = 0;
    REP(i, s.size()) {
        if(s[i] == '1') {
            renzoku++;
            if(renzoku == m) {
                cout << "-1" << endl;
                return 0;
            }
        } else {
            renzoku = 0;
        }
    }

    /* ゴールから見ていく（辞書順最小にしたいので） */
    int now = 0;
    vector<int> ans;
    while(now != n) {
        REP_REV(i, min(n - now, m) + 1) {
            if(s[now + i] == '0') {
                ans.push_back(i);
                now += i;
                break;
            }
        }
    }

    reverse(ans.begin(), ans.end());
    REP(i, ans.size()) {
        cout << ans[i] << " "; 
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 1144
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val S = Array(N) { sc.next() }.toSet()
        pw.println(S.count())
    }
}


Measured memory_bytes: 75124
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  200005
ll w[N],b[N];
int main()
{
	ios
	ll n,i,j;
	cin>>n;
	string s;
	cin>>s;
	for(i=1;i<=n;i++){
		if(s[i-1]=='.')w[i]=1;
		else b[i]=1;
		w[i]+=w[i-1];
		b[i]+=b[i-1];
	}
	ll ans=hell;
	for(i=0;i<=n;i++){
		ans=min(ans,b[i]+(w[n]-w[i]));
	}
	cout<<ans;
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var x = Partition(A, 0, n - 1);

            for (var i = 0; i < n; i++)
            {
                if (i != 0) Console.Write(" ");
                if (i == x) Console.Write($"[{A[i]}]");
                else Console.Write(A[i]);
            }

            Console.WriteLine();
        }

        static int Partition(int[] A, int p, int r)
        {
            var x = A[r];
            var i = p - 1;
            for (var j = p; j < r; j++)
            {
                if (A[j] <= x)
                {
                    i++;
                    Swap(ref A[i], ref A[j]);
                }
            }
            
            Swap(ref A[i + 1], ref A[r]);

            return i + 1;
        }

        public static void Swap<T>(ref T one, ref T two)
        {
            var temp = one;
            one = two;
            two = temp;
        }
    }
}



Measured memory_bytes: 25624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		
		for (int i = k; i < n; i++) {
			System.out.println(a[i - k] < a[i] ? "Yes" : "No");
		}
	}

}

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

int main() {
	int N;
	cin >> N;
	vector<long long> A(N + 1);
	for (int i = 1; i <= N; i++)cin >> A[i];

	int M = 100000;

	vector<long long> count(M + 1, 0);
	for (int i = 1; i <= N; i++)count[A[i]]++;

	long long S = 0;
	for (int i = 1; i <= N; i++)S += A[i];

	int Q;
	cin >> Q;
	for (int q = 1; q <= Q; q++) {
		long long b, c;
		cin >> b >> c;

		long long memo = count[b];
		count[b] = 0;
		count[c] += memo;
		S += memo * (c - b);
		cout << S << endl;
	}
}

Measured memory_bytes: 4828
n = int(input())
dp = [0, 0, 0]
 
for i in range(n):
    A = [int(i) for i in input().split()]
    dp = [A[0] + max(dp[1], dp[2]), A[1] + max(dp[0], dp[2]), A[2] + max(dp[0], dp[1])]
 
print( max(dp) )

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

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

	string a, b, ans;
	cin >> a;
	b += a;
	cin >> a;
	b += a;
	cin >> a;
	b += a;
	ans += b[0];
	ans += b[4];
	ans += b[8];
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

MOD = 1000000007

n,m = getMN()
anums = getlist()
bnums = getlist()

#ある時点でのx幅の総パターンの和
#x_i * (i-1) - (累積和)
def calc_accum_width(nums):
    x_pos_acc = 0
    x_width_acc = 0

    for i, a in enumerate(nums):
        x_width_acc += a * i - x_pos_acc
        x_pos_acc += a

    return x_width_acc

x_acc = calc_accum_width(anums)
y_acc = calc_accum_width(bnums)

print(x_acc * y_acc % MOD)


Measured memory_bytes: 18556
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)
 
count = 0
while a_arr.all?{|a| a % 2 == 0} do
  count += 1
  a_arr.map!{|a| a /= 2}
end
 
puts count

Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

void findDivisor(int n, vector<int>& divisor)
{
    divisor.clear();
    stack<int> stk;
    for(int i=1; i*i<=n; ++i){
        if(n % i == 0){
            divisor.push_back(i);
            if(i * i < n)
                stk.push(n / i);
        }
    }
    while(!stk.empty()){
        divisor.push_back(stk.top());
        stk.pop();
    }
}

const int MOD = 1000000007;

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

int main()
{
    int n, k;
    cin >> n >> k;

    vector<long long> v;
    if(n % 2 == 0){
        n /= 2;
        vector<int> div;
        findDivisor(n, div);

        int m = div.size();
        v.assign(m, 0);
        for(int i=0; i<m; ++i){
            int x = div[i];
            v[i] = x * power(k, x) % MOD;
            for(int j=0; j<i; ++j){
                int y = div[j];
                if(x % y == 0){
                    v[i] -= v[j] * (x / y) % MOD;
                    v[i] += MOD;
                    v[i] %= MOD;
                }
            }
        }
    }
    else{
        vector<int> div;
        findDivisor(n, div);

        int m = div.size();
        v.assign(m, 0);
        for(int i=0; i<m; ++i){
            int x = div[i];
            v[i] = x * power(k, (x+1)/2) % MOD;
            for(int j=0; j<i; ++j){
                int y = div[j];
                if(x % y == 0){
                    v[i] -= v[j] * (x / y) % MOD;
                    v[i] += MOD;
                    v[i] %= MOD;
                }
            }
        }
    }

    long long ans = accumulate(v.begin(), v.end(), 0LL) % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1,1,-1,-1,2,2,-2,-2}; //knight moves
///int ky[]={2,-2,2,-2,1,-1,1,-1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};  //eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};  //eight direction
 
///using namespace __gnu_pbds;
using namespace std;
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
   	int n,q,k;
   	while(sf("%d %d %d",&n,&q,&k)==3)
   	{
   		int cnt[n+5];
   		memset(cnt,0,sizeof cnt);
   		for(int i=0;i<k;i++)
   		{
   			int x;
   			sf("%d",&x);
   			cnt[x]++;
   		}

   		for(int i=1;i<=n;i++)
   		{
   			int sub=k-cnt[i];
   			if(q-sub<=0)puts("No");
   			else puts("Yes");
   		}
   	}
    return 0;
}
 









 




























Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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

  ll N;
  cin >> N;
  ll arr[N];
  for (ll i = 0; i < N; i++) {
    cin >> arr[i];
  }

  ll dp[N];

  dp[0] = 0;
  dp[1] = abs(arr[1] - arr[0]);

  for (ll i = 2; 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 - 1];
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  
  for(int i=0;i<n ;i++)cin >> a[i];
  
  int res = 0;
  
  for(int i=0 ; i<n-1 ; i++){
    for(int j=i+1 ; j<n ; j++){
      int div = abs(a[i]-a[j]);
      res = max(div,res);
    }
  }
  
  cout << res << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  ll x;
  cin >> x;
  ll ans = x / 11;
  if(x % 11 == 0)cout << ans * 2 << endl;
  else if(x % 11 > 0 && x % 11 <= 6)cout << ans * 2 + 1 << endl;
  else cout << ans * 2 + 2 << endl;
}


Measured memory_bytes: 256
N = int(input())
#2<=N<10**12

num=int(N**(1/2)+1)
count=N+1-2
##N=a*b
#output=a+b-2
#積なので対称性よりa<=bとしてオッケー
for i in range(1,num):
    if N%i==0:
       count=min(count,i+N//i -2)
print(count)

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

vector<vector<int>> G;
deque<bool> used;
deque<int> ans;

void print(int n = -1) {
  if (~n) cout << n << " : ";
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << (i + 1 == ans.size() ? "\n" : " ");
  }
}

void dfs(int v, bool f) {
  if (f) ans.push_front(v);
  else ans.push_back(v);
  used[v] = true;

  // print(v);

  for (auto to : G[v]) {
    if (used[to]) continue;
    // ans.(f ? push_front : push_back)(v);

    dfs(to, f);
    break;
  }
}

int main() {
  int n, m;
  cin >> n >> m;

  G.resize(n + 1);
  int l, r;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;

    G[u].push_back(v);
    G[v].push_back(u);
    l = u, r = v;
  }

  used.resize(n + 1);
  used[l] = used[r] = true;
  dfs(l, true);
  dfs(r, false);

  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << (i + 1 == ans.size() ? "\n" : " ");
  }
}


Measured memory_bytes: 6784
#include <stdio.h>

int main()
{
  int r,c,x,sum,i,j;
  int data[101][101];
  scanf("%d",&r);
  scanf("%d",&c);


  for (i=0;i<r;i++){
    for (j=0;j<c;j++){
      scanf("%d",&x);
      data[i][j]=x;
    }
  }

  for (i=0;i<r;i++){
    sum=0;
    for (j=0;j<c;j++){
      sum+=data[i][j];
    }
    data[i][c]=sum;
  }

  for (i=0;i<r;i++){
    for (j=0;j<c;j++){
      printf("%d ",data[i][j]);
    }
    printf("%d\n",data[i][c]);
  }

  for (j=0;j<c+1;j++){
    sum=0;
    for (i=0;i<r;i++){
      sum+=data[i][j];
    }
    data[r][j]=sum;
  }

  for (j=0;j<c;j++){
    printf("%d ",data[r][j]);
    }
  printf("%d\n",data[r][c]);



  return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// // assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm vi st gin

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

    int2(n, m);

    vi cnt(n, 0);
    rep(i, m) {
        int2(a, b);
        cnt[a-1]++; cnt[b-1]++;
    }
    rep(i, n) {
        if (cnt[i] & 1) {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }
    std::cout << "YES" << std::endl;

    return 0;
}


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

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

    int ct = 0;
    int n_size = s.size();
    rep(i,n_size/2) {
        if (s[i] != s[n_size-1-i]) ct++;
    }
    cout << ct << endl;
    return 0;
}

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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD (int)10e9+7
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

const ll mxN=1e5+5;
ll n,w;
ll temp_one, temp_two;

ll dp[mxN]; // the minimum weight to achieve dp[v] = min(dp[v], dp[v-curr_v]+curr_w);
bool visited[mxN];

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

    memset(dp,0x3f,sizeof(ll)*mxN);
    cin >> n >> w;
    
    dp[0]=0;
    for(ll i = 0;i < n;i++) {
        cin >> temp_one >> temp_two;
    
        for(ll value = mxN-temp_two; value >= 0; value--)
            min_self(dp[value+temp_two], dp[value]+temp_one);
    }
    
    ll temp_max = 0;
    for(ll i = 0; i<mxN; i++) {
        if(dp[i]<=w)
            max_self(temp_max,i);
    }
    cout << temp_max << endl;
    
    return 0;

}



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

int main(){
  int n;
  cin >> n;
  __float128 x=1;
  int64_t a=1,b;
  bool ok=true;
  for(int i=0;i<n;i++){
    cin >> b;
    if(b==0){
      cout << 0 << endl;
      return 0;
    }
    a*=b;
    x*=b;
    if(x>1000000000000000000||a>1000000000000000000)
      ok=false;
  }
  cout << (ok?a:-1) << endl;
  return 0;
}

Measured memory_bytes: 3576
<?php
fscanf(STDIN, "%s", $str);

try {
	if (check($str[0], 'K')) {
		// A
		if ($str[1] . $str[2] . $str[3] == 'KIH') {
			// AKIH
			if (check($str[4], 'B')) {
				// AKIHA
				if ($str[5] == 'B') {
					// AKIHAB
					if (check($str[6], 'R')) {
						// AKIHABA
						if (isset($str[7]) and $str[7] == 'R') {
							// AKIHABAR
							if (!isset($str[8]) or ($str[8] == 'A') and !isset($str[9])) {
								// true
								echo 'YES';
							} else {
								throw new Exception('fail');
							}
						} else {
							throw new Exception('fail');
						}
					} else {
						// AKIHABR
						if (!isset($str[7]) or (($str[7] == 'A') and !isset($str[8]))) {
							echo 'YES';
						} else {
							throw new Exception('fail');
						}
					}
				} else {
					throw new Exception('fail');
				}
			} else {
				// AKIHB
				if (check($str[5], 'R')) {
					// AKIHBA
					if (isset($str[6]) and $str[6] == 'R') {
						// AKIHABAR
						if (!isset($str[7]) or (($str[7] == 'A') and !isset($str[8]))) {
							echo 'YES';
						} else {
							throw new Exception('fail');
						}
					} else {
						throw new Exception('fail');
					}
				} else {
					// AKIHBR
					if (!isset($str[6]) or (($str[6] == 'A') and !isset($str[7]))) {
						echo 'YES';
					} else {
						throw new Exception('fail');
					}
				}
			}
		} else {
			throw new Exception('fail');
		}
	} else {
		// K
		if ($str[1] . $str[2] == 'IH') {
			// KIH
			if (check($str[3], 'B')) {
				// KIHA
				if (isset($str[4]) and $str[4] == 'B') {
					// KIHAB
					if (check($str[5], 'R')) {
						// KIHABA
						if (isset($str[6]) and $str[6] == 'R') {
							// KIHABAR
							if (!isset($str[7]) or (($str[7] == 'A') and !isset($str[8]))) {
								// true
								echo 'YES';
							} else {
								throw new Exception('fail');
							}
						} else {
							throw new Exception('fail');
						}
					} else {
						// KIHABR
						if (!isset($str[6]) or (($str[6] == 'A') and !isset($str[7]))) {
							//true
							echo 'YES';
						} else {
							throw new Exception('fail');
						}
					}
				} else {
					throw new Exception('fail');
				}
			} else {
				// KIHB
				if (check($str[4], 'R')) {
					// KIHBA
					if (isset($str[5]) and $str[5] == 'R') {
						// KIHABAR
						if (!isset($str[6]) or (($str[6] == 'A') and !isset($str[7]))) {
							// true
							echo 'YES';
						} else {
							throw new Exception('fail');
						}
					} else {
						throw new Exception('fail');
					}
				} else {
					// KIHBR
					if (!isset($str[5]) or (($str[5] == 'A') and !isset($str[6]))) {
						// KIHBR
						echo 'YES';
						// true
					} else {
						throw new Exception('fail');
					}
				}
			}
		} else {
			throw new Exception('fail');
		}
	}
} catch (Exception $e) {
	echo 'NO';
}

function check ($str, $next_char) {
	if ($str == 'A') {
		return true;
	} elseif($str == $next_char)  {
		return false;
	} else {
		throw new Exception('fail');
	}
}

Measured memory_bytes: 3828
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int a;
string s;

signed main(){
    cin >> a >> s;
    if(a >= 3200)cout << s << endl;
    else cout << "red" << endl;

    return 0;
}
/*


*/

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

int main(){
//srandom((unsigned long)time(NULL));

int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int cnt=0;
for(int i=1;i<n;i++){
  int v=a[i];
  int j=i-1;
 // if(a[j]>a[i])cnt++;
  while(j>=0 && a[j]>v){
    cnt++;
    a[j+1]=a[j];
    j--;
  }
  a[j+1]=v;
}
for(int i=0;i<n-1;i++){
  cout<<a[i]<<" ";
}
cout<<a[n-1]<<endl;
cout<<cnt<<endl;

return 0;
}




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

const int VMAX = 100;
int G[VMAX][VMAX];
int used[VMAX];
int V, E;

bool dfs(const int idx, const int original, const bool isinitial) {
	if (!isinitial) {
		used[idx] = true;
		if (idx == original) return true;
	}
	bool res = false;
	for (int i = 0; i < VMAX; i++) {
		if (G[idx][i] && !used[i]) {
			res |= dfs(i, original, false);
		}
		if (res == true) break;
	}
	return res;
}

int main(void) {
	cin >> V >> E;
	for (int i = 0; i < VMAX; i++) {
		for (int j = 0; j < VMAX; j++) {
			G[i][j] = 0;
			used[i] = false;
		}
	}
	for (int i = 0; i < E; i++) {
		int s, t; cin >> s >> t;
		G[s][t] = 1;
	}

	for (int begin = 0; begin < V; begin++) {
		memset(used, 0, sizeof(used));
		if (dfs(begin, begin, true)) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}


Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

ll Gcd(ll a,ll b){
  //op(a);
  while(b){
    a=(a%b);
    swap(a,b);
    
  }
  return a;
}


//
void solve(long long A, long long B){
  op(A*B/Gcd(A,B))
  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)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<math.h>
using namespace std;
int main() {
	int n, d;
	cin >> n >> d;
	int count = 0;
	int buf[15][15];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> buf[i][j];
		}
	}int sum = 1;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int ans = 0;
			for (int k = 0; k < d; k++) {
				int a = (buf[i][k] - buf[j][k]) * (buf[i][k] - buf[j][k]);
				ans = ans + a;
			}
			int b = sqrt(ans);
			for (int x = 0; x <= b; x++) {
				if (x * x == ans) {
					count++;
				}
			}
		}
	}
	cout << count << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int N_MAX = 100;
int main (void) {
  int n;
  int a[N_MAX];
  int alice = 0;
  int bob = 0;

  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];

  sort(a, a + n, greater<int>());

  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) alice += a[i];
    else bob += a[i];
  }

  cout << alice - bob << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[210000];
int q[210000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
	int b;scanf("%d",&b);
	for(int i=0;i<b;i++)scanf("%d",q+i);
	std::sort(q,q+b);
	int at=0;
	for(int i=0;i<b;i++){
		while(at<a){
			if(q[i]==p[at]){
				at++;break;
			}else if(at==a-1){
				printf("NO\n");return 0;
			}
			at++;
		}
	}
	printf("YES\n");
}

Measured memory_bytes: 1664
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def unite(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

    def get_size(self, x):
        return -self.table[self._root(x)]


n, m = map(int, input().split())
uft = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uft.unite(a, b)
print(-min(uft.table))


Measured memory_bytes: 14536
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()[:-1]

    res = 0
    A = {'r': P, 's': R, 'p': S}
    for k in range(K):
        tmp = A[T[k]]
        cnt = 1
        for i in range(k,N-K,K):
            # print([T[i], cnt])
            if i+K>=N:
                break
            if T[i]==T[i+K]:
                cnt += 1
            else:
                res += tmp * ((cnt + 1) // 2)
                tmp = A[T[i+K]]
                cnt = 1
            # print(res)  
        res += tmp * ((cnt + 1) // 2)

    print(res)    


if __name__ == '__main__':
    main()

Measured memory_bytes: 67052
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
using namespace std;
const int N=110;

int32_t main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if (k%2==0){
        cout << a-b;
    }
    else{
        cout << b-a;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
// priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
priority_queue<ll> PQ;

int main(){
  int n;
  int a[105];

  int i;
  scanf("%d", &n);
  for(i = 1;i <= n;i++) scanf("%d", &a[i]);

  int ans = 0;
  for(i = 1;i <= n;i++){
    if(i % 2 == 1 && a[i] % 2 == 1) ans++;
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3824
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long a,b,c,x,y,d,e,f;
  cin >> a >> b >> c >> x >> y;
  d=min(a,c*2),e=min(b,c*2),f=min(x,y);
  cout << f*min(a+b,c*2)+(x-f)*d+(y-f)*e << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=0;y=0
for i in range(n):
  if a[i]<b[i]:
    x+=(b[i]-a[i])//2
  else:
    y+=(a[i]-b[i])
print('Yes' if x>=y else 'No')

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

using namespace std;

typedef long long ll;

ll N;

int dfs(string s) {
    if (atoll(s.c_str()) > N) {
        return 0;
    }

    bool is753=false;
    string t = s;
    sort(t.begin(),t.end());
    unique(t.begin(),t.end());
    if (t[0]=='3' && t[1]=='5' && t[2]=='7') {
        is753=true;
    }

    int ret=0;
    if (is753) ret = 1;

    ret += dfs(s + "7");
    ret += dfs(s + "5");
    ret += dfs(s + "3");

    return ret;
}

int main() {
    cin>>N;

    cout << dfs("") << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())

ans = [[0 for i in range(14)]for j in range(15)]
for i in range(1,10):
    for j in range(1,10):
        for keta in range(1,8):
            if keta == 1:
                if i == j and i <= n:
                    ans[i][j] += 1
            elif keta == 2:
                if i*10 + j <= n:
                    ans[i][j] += 1
            else:
                mid = keta - 2
                nummin = i*10**(keta-1) + j
                if nummin > n:
                    continue
                nummax = nummin + 10**(keta-1) - 10
                if nummax <= n:
                    ans[i][j] += 10**mid
                else:
                    tmp = n - nummin
                    ans[i][j] += tmp//10 + 1

res  = 0
for i in range(1,10):
    for j in range(1,10):
        res += ans[i][j] * ans[j][i]
print(res)

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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define ll  long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi      vector<int>
#define pii     pair<int,int>
#define piii    pair<pair<int,int>,int>
#define all(v)  v.begin(), v.end()

int mod = 1000000007;
const int N = 1005;

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

    ll n, m;
    cin >> n >> m;
    if ( n == 1 and m == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    if ( m == 1 or n == 1)
    {
        cout << max(n,m) - 2 << endl;
        return 0;
    }
    cout << (n-2)*(m-2);

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

ans = 0
S = input()
n = len(S)

def dfs(i,f):
    if i == n-1: return sum(list(map(int, f.split("+"))))

    return dfs(i+1, f+S[i+1]) + dfs(i+1, f+"+"+S[i+1])

print(dfs(0,S[0]))

Measured memory_bytes: 12560
import math

n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

x = l[0]
for i in range(1,n):
    #y = math.ceil(x[0] / l[i][0]) # 'ceil'では 'WA'.
    #z = math.ceil(x[1] / l[i][1]) # 'ceil'では、商が桁の大きなfloatの場合、高次桁で結果に狂いが生じる.
    y = -(-x[0] // l[i][0])
    z = -(-x[1] // l[i][1])
    x = [max(y, z) * j for j in l[i]]

print(sum(x))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
typedef long long int ll;
typedef pair<int, int> P;
 
const long long INF = 3e18 + 12;
const int inf = 1e9;
 
int keta_sum(int a) {
  string sta = to_string(a);
  int keta = sta.length();
  int sum = 0;
  rep(i, keta) {
    sum += sta[i] - '0';
  }
 
  return sum;
}
 
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  repi(i, 1, n + 1) {
    int sum = keta_sum(i);
    if (sum >= a && sum <= b) {
      ans += i;
    }
  }
 
  cout << ans << endl;
  return 0;
}

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

def main():
    x = int(input())

    MAX_PRIME = int(1e5) + 100
    primes = []
    is_prime = [True] * (MAX_PRIME+1)
    for i in range(2, MAX_PRIME+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_PRIME+1, i):
                is_prime[j] = False
    
    for p in primes:
        if p >= x:
            print(p)
            break
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 4068
/*
* Author. Silviase(@silviasetitech)
* For AtCoder
*/

import java.util.*;
import java.lang.*;
import java.math.*;


public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        if (m % n  == 0) {
            System.out.println(m + n);
        } else {
            System.out.println(m - n);
        }

        sc.close();
    }
    private static int gcd(int m, int n) {
        if(m < n) {
            return gcd(n, m);
        }
        if(n == 0){
            return m;
        } 
        return gcd(n, m % n);
    }
}

Measured memory_bytes: 22612
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], k = tmp[1];
    string s = readln.chomp;
    writeln(s[0..k-1] ~ s[k-1].toLower.to!string ~ s[k..$]);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.typecons;

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long MOD = (long)Math.pow(10, 9) + 7;
    int n = sc.nextInt();
    long[][] rui = new long[60][2];
    for(int i = 0; i < n; i++) {
      long a = sc.nextLong();
      for(int j = 0; j < 60; j++) {
        rui[j][(int)(a % 2)]++;
        a /= 2;
      }
    }
    long ans = 0;
    for(int i = 0; i < 60; i++) {
      long t = (long)Math.pow(2, i) % MOD;
      t = (t * rui[i][0]) % MOD;
      t = (t * rui[i][1]) % MOD;
      ans = (ans + t) % MOD;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 90444
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){

	int n;
	cin >> n;
	ll h[100010];
	FOR(i,n){
		cin >> h[i];
	}
	ll cnt=h[0];
	bool ans=1;
	for(int i=1;i<n;i++){
		if(h[i]+1<cnt){
			ans=0;
		}
		chmax(cnt,h[i]);
	}
	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}


}

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

using namespace std;


int main(){
    long long x;
    cin >> x;
    for(long long i = -1000; i <= 1000; i++){
        for(long long j = -1000;j <= 1000; j++){
            if(pow(i, 5) - pow(j, 5) == x){
                cout << i << ' ' << j << '\n';
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3868
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N, M = MI()

    # graph = [[1] * (M+2) for i in range(N+2)]
    # for i in range(1, N+1):
    #     for j in range(1, M+1):
    #         for v in product([0, -1, 1], repeat=2):
    #             graph[v[0] + i][v[1] + j] = 1 - graph[v[0] + i][v[1] + j]

    # ans = 0
    # for i in range(1, N+1):
    #     for j in range(1, M+1):
    #         if graph[i][j] == 0:
    #             ans += 1

    # print(ans)

    if N == 1 and M == 1:
        print(1)
    elif M == 1 or N == 1:
        print(max(N, M) - 2)
    else:
        print((M - 2) * (N - 2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63980
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int x = sc.nextInt();

		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Math.abs(x - sc.nextInt());
		}
		sc.close();

		int ans = a[0];
		for (int i = 1; i < n; i++) {
			ans = gcd(a[i], ans);
		}
		System.out.println(ans);
	}
	public static int gcd(int x, int y) {
		if (y == 0) {
			return x;
		}

		return gcd(y, x%y);
	}
}

Measured memory_bytes: 49728
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


t1,t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1,b2 = map(int, input().split())

a1 *= t1
a2 *= t2
b1 *= t1
b2 *= t2

if a1+a2==b1+b2:
    ans = "infinity"
else:
    if a1+a2 < b1+b2:
        a1,a2,b1,b2 = b1,b2,a1,a2
    # a1+a2が大きい
    if a1>b1:
        ans = 0
    else:
        ans = ((b1-a1) // (a1+a2-b1-b2)) * 2 + 1
        if (b1-a1) % (a1+a2-b1-b2) ==0:
            ans -= 1
print(ans)    

Measured memory_bytes: 38468
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  vector<int>a;
  for(int i=0;i<3;i++){
    int x;
    cin>>x;
    a.push_back(x);
  }
  sort(a.begin(),a.end());
  if(a[0]==a[1]&&a[1]!=a[2] || a[0]!=a[1]&&a[1]==a[2])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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



int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll max = -10000000000;
  if(a >= 0 && c >= 0) max = b * d;
  if(a >= 0 && c <= 0){
    if(d >= 0) max = b * d;
    if(d <= 0) max = a * d;
  }
  if(a <= 0){
    if(b >= 0){
      if(c >= 0) max = b * d;
      if(c <= 0){
          if(d >= 0 && (a * c) >= (b * d)) max = a * c;
          if(d >= 0 && (a * c) <= (b * d)) max = b * d;
          if(d <= 0) max = a * c;
      }
    }
    if(b <= 0){
      if(c >= 0) max = b * c;
      if(c <= 0) max = a * c; 
    }
  }
  cout << max << endl;

}

Measured memory_bytes: 3628
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=1;i<=n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int i,j,k;
  int n,m,a,b;
  int s,g,v,p;
  int cost[25][25]={};

  cin>>n>>m;

  rep(i,n)rep(j,n)cost[i][j]=INF;
  rep(i,n)cost[i][i]=0;

  rep(i,m){
    scanf("%d,%d,",&a,&b);
    scanf("%d,%d",&cost[a][b],&cost[b][a]);
  }
  scanf("%d,%d,%d,%d",&s,&g,&v,&p);

  rep(k,n)rep(i,n)rep(j,n)
    cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);

  cout<<v-p-cost[s][g]-cost[g][s]<<endl;

}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

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

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

  i64 ans = N * M / gcd(N, M);
  i64 A = N / gcd(N , M);
  i64 B = M / gcd(N , M);
  for(int i = 0;A * i < s.size();i++){
    if(s[i * A] != t[i * B]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512